Matchmaking using Apache Webserver

Started by
10 comments, last by Philip Borgstr 11 years, 5 months ago
Is it possible with an unmodified version of Apache HTTP web server to make an complete matchmaking system or do I have to have an actual root access server which I can install my custom software onto? The matchmaker I want to make bases itself that a client connects and signs up to the matchmaker and then the server loops through the list checking for matches and updating information. Once the a match is made the server tells the clients to connect to each other. I am rather new to network programming so my bad if this is an obvious question.
Advertisement
AFAIK, a 'naked' apache installation is basically just a file server. Usually you'll install some server-side modules that allow you to dynamically generate responses (instead of only responding with static files), such as mod_php (which lets you run PHP code) or mod_cgi (which lets you run CGI scripts).

Assuming your apache installation has some kind of server-side language installed (which should be a standard feature with any web-hosting company), then yes you can implement loops/searches/matching/etc...
No, you need some plugin for serverside scripts. (I don't know of any webhost that doesn't provide atleast php support though)

Edit: Beaten :(
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Okey, miss information by me, it is not an raw installation of the apache server, it has CGI scripts and php support. Thanks for the information!

Okey, miss information by me, it is not an raw installation of the apache server, it has CGI scripts and php support. Thanks for the information!


the server can't initiate script execution on its own unless you can run a standalone application.

a fairly simple workaround is to have the users query the server at a fixed interval instead. , you could also let the scripts run for a few seconds before returning a wait message to the client (that way clients don't have to make as many queries), cheap webhosts most likely won't allow your scripts to run for very long before terminating though. (max runtime is a php.ini setting, default is 30 seconds but cheap hosts might reduce it to prevent customers from hogging too much server resources)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

[quote name='philipborg' timestamp='1343897154' post='4965447']
Okey, miss information by me, it is not an raw installation of the apache server, it has CGI scripts and php support. Thanks for the information!


the server can't initiate script execution on its own unless you can run a standalone application.

a fairly simple workaround is to have the users query the server at a fixed interval instead. , you could also let the scripts run for a few seconds before returning a wait message to the client (that way clients don't have to make as many queries), cheap webhosts most likely won't allow your scripts to run for very long before terminating though. (max runtime is a php.ini setting, default is 30 seconds but cheap hosts might reduce it to prevent customers from hogging too much server resources)
[/quote]

This was one of my thought on how to do this... My webhost is pretty expensive so I think they have 30 seconds. Can't I make so that the clients sends an message to an php script which checks if it has gone more then 10 seconds since the last update. If it has gone more then 10 seconds it runs the script again. The script is then executed directly and maybe is executed in 2 seconds. Is this a good method or is it better to let the clients wait before they will restart the script? With my method overloading the server will be hard and it will always run as often as I like. Maybe the best method is a combined method, 2 parts of server and a wait system?

[quote name='SimonForsman' timestamp='1343897415' post='4965450']
[quote name='philipborg' timestamp='1343897154' post='4965447']
Okey, miss information by me, it is not an raw installation of the apache server, it has CGI scripts and php support. Thanks for the information!


the server can't initiate script execution on its own unless you can run a standalone application.

a fairly simple workaround is to have the users query the server at a fixed interval instead. , you could also let the scripts run for a few seconds before returning a wait message to the client (that way clients don't have to make as many queries), cheap webhosts most likely won't allow your scripts to run for very long before terminating though. (max runtime is a php.ini setting, default is 30 seconds but cheap hosts might reduce it to prevent customers from hogging too much server resources)
[/quote]

This was one of my thought on how to do this... My webhost is pretty expensive so I think they have 30 seconds. Can't I make so that the clients sends an message to an php script which checks if it has gone more then 10 seconds since the last update. If it has gone more then 10 seconds it runs the script again. The script is then executed directly and maybe is executed in 2 seconds. Is this a good method or is it better to let the clients wait before they will restart the script? With my method overloading the server will be hard and it will always run as often as I like. Maybe the best method is a combined method, 2 parts of server and a wait system?
[/quote]

You could do that, if the host allows scripts to run for a few second each script request could do a simple:
$matchResponse = false;
$startTime = $currentTime = getcurrenttimeinseconds();
$maxExecutionTime = max(ini_get("max_execution_time")/2,5); //set the scripts max runtime to whichever is highest of half the servers max time or 10
while ($currentTime-$startTime < $maxExecutionTime && !$matchResponse) {
$matchResponse = checkForMatch();
if ($matchResponse) {
echo $matchResponse;
}
usleep(100000); //sleep for atleast 100 ms
$currentTime = getcurrenttimeinseconds();
}

This would allow the script to constantly check for up to 10 seconds on a single request without using much CPU resources (fewer requests = less bandwidth used)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Thanks for the response! I believe that is a solid way to handle it. Thanks to all of you for great ideas and tips happy.png
My question is, why do you need an HTTP server for you to do your matchmaking? Is your client a standard web browser?

My question is, why do you need an HTTP server for you to do your matchmaking? Is your client a standard web browser?


I'd guess its because it removes the need to pay for and run a proper server yourself. You can get a webhost with php support for pretty much nothing while a dedicated server that lets you run your own software cost alot more.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

This topic is closed to new replies.

Advertisement