Polling performance on shared host

Shlomo Goldstein asked:

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?

My answer:

The bottleneck is that your shared hosting provider will kick you off for hogging the CPU.

Apache can handle hundreds or thousands of requests per second, depending on the server and any performance tuning in place. The problem is that for “obtaining game status” you’re going to hit your application, which is going to do some calculations, which is much harder to serve. You might only be able to do dozens of these per second if you had the server all to yourself.

A solution there is to do the status calculation in a background worker, write a file with the status every second or half second or whatever, and have your AJAX fetch that file.

Though, if your game is even marginally successful, you’ll have to move off shared hosting and onto something more reasonable. Shared web hosting is not really designed for high performance or mission critical web sites.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.