• Create Account

## Matchmaking using Apache Webserver

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1philipborg  Members

337
Like
0Likes
Like

Posted 02 August 2012 - 02:16 AM

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.

### #2Hodgman  Moderators

49387
Like
2Likes
Like

Posted 02 August 2012 - 02:20 AM

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...

Edited by Hodgman, 02 August 2012 - 02:23 AM.

### #3SimonForsman  Members

7584
Like
2Likes
Like

Posted 02 August 2012 - 02:20 AM

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

Edited by SimonForsman, 02 August 2012 - 02:21 AM.

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!

### #4philipborg  Members

337
Like
0Likes
Like

Posted 02 August 2012 - 02:45 AM

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!

Edited by philipborg, 02 August 2012 - 02:47 AM.

### #5SimonForsman  Members

7584
Like
0Likes
Like

Posted 02 August 2012 - 02:50 AM

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)

Edited by SimonForsman, 02 August 2012 - 02:52 AM.

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!

### #6philipborg  Members

337
Like
0Likes
Like

Posted 02 August 2012 - 03:50 AM

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)

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?

### #7SimonForsman  Members

7584
Like
0Likes
Like

Posted 02 August 2012 - 04:04 AM

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)

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?

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)
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!

### #8philipborg  Members

337
Like
0Likes
Like

Posted 02 August 2012 - 04:07 AM

Thanks for the response! I believe that is a solid way to handle it. Thanks to all of you for great ideas and tips

### #9Firestryke31  Members

350
Like
0Likes
Like

Posted 02 August 2012 - 07:49 PM

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

### #10SimonForsman  Members

7584
Like
0Likes
Like

Posted 03 August 2012 - 01:06 PM

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.
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!

### #11Firestryke31  Members

350
Like
0Likes
Like

Posted 03 August 2012 - 06:13 PM

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.

### #12philipborg  Members

337
Like
0Likes
Like

Posted 07 November 2012 - 01:59 PM

I do not have any bandwidth limits or memory limits so for me it is a easy choice even though I admit an VPS or dedicated server would be nice.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.