Sign in to follow this  

Matchmaking using Apache Webserver

This topic is 1859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 ([i]instead of only responding with static files[/i]), such as mod_php ([i]which lets you run PHP code[/i]) or mod_cgi ([i]which lets you run [url="http://en.wikipedia.org/wiki/Common_Gateway_Interface"]CGI scripts[/url][/i]).

Assuming your apache installation has some kind of server-side language installed ([i]which should be a standard feature with any web-hosting company[/i]), then yes you can implement loops/searches/matching/etc... Edited by Hodgman

Share this post


Link to post
Share on other sites
[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!
[/quote]

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) Edited by SimonForsman

Share this post


Link to post
Share on other sites
[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!
[/quote]

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?

Share this post


Link to post
Share on other sites
[quote name='philipborg' timestamp='1343901058' post='4965464']
[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!
[/quote]

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)

Share this post


Link to post
Share on other sites
[quote name='Firestryke31' timestamp='1343958544' post='4965711']
My question is, why do you need an HTTP server for you to do your matchmaking? Is your client a standard web browser?
[/quote]

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.

Share this post


Link to post
Share on other sites
The problem with that is that most of those hosts also have some odd, not always up front limits and worst case completely shut down the site with a "Bandwidth Exceeded" message until next month. You don't need dedicated hardware for a start up game, a VPS is a good mid way point with more control than a shared AMP server but less cost than a dedicated. In the other thread about shoehorning HTTP into a role it wasn't designed for I posted a link to a VPS company who's minimum plan was $4USD a month (albeit the stats are kind of piddly for a medium traffic server like matchmaking, the next one up's only $7). Usually by the time you've outgrown the stats for it you're making enough to upgrade to a more permanent solution, if not at very least the next tier plan.

Share this post


Link to post
Share on other sites

This topic is 1859 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this