Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am planning on writing a small browser game.

The webserver is a shared server, with no root / install possible.

I want to use AJAX for client/server communication. There will be 12 players.

So each player would be polling the server for the current game status every X milliseconds (let's say 200ms). So that would be 200ms x 12 players x 5 = 60 requests per second

Can Apache handle those requests?

What might be the bottlenecks when using this attempt?

share|improve this question
    
Thanks. This question helped me a lot understanding about Websockets. –  Sarah Apr 8 '13 at 12:50
add comment

1 Answer

up vote 2 down vote accepted

Apache can certainly handle the requests, but you will want to do some careful planning to ensure that things work as expected.

In order to handle such a high rate of requests with minimal latency, clients MUST be using HTTP keepalives. Keepalives are sometimes disabled in web servers.

You will also want to be very careful on the client-side to not issue a new request if the previous one is still pending. You might also want to disregard a response if it took too long.

If your game requires this request rate, it may be a good idea to limit it to players with low latency to your server (say < 50ms) which will prevent players outside your geographical region (you could always set up new servers for those players elsewhere).

Personally I would always recommend using a FastCGI backend for Apache (or maybe Nginx or some other web server). Then you will need a pool of processes / threads to run your FastCGI. This does not need to run as root (and indeed, should not).


In the longer term though, if the client browsers support it, it might be a good idea to use Websockets.

share|improve this answer
    
Thanks I will research about your suggestions. Have never used FastCGI or Websockets. Do you have a introductive tutorial you would recommend? –  Indianer Oct 12 '12 at 7:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.