AJAX Optimisation

Soldato
Joined
18 Oct 2002
Posts
2,910
Location
London
I am currently developing a game which will work using AJAX.

It's a turn based game where every user has 90 seconds to take their turn (although it might not take them that long). There is up to 10 players per game.

I had thought that I could just have each client checking to see if the other players had played their turn by calling a page from the server every 5 seconds. This way play can be updated on a near live basis.

Games can take around 3 hours to complete. This could work out to be 21600 requests per game!

How should I look to optimise this? I have been looking in to stuff like Comet but not sure if I can implement it using PHP.

Any of the bright sparks here have any ideas?
 
Im sure AJAX can handle that fine. Just return as little data as possible and let the clients process the data as much as possible if you want to keep server load down. That number of requests is not really a problem anyway as long as your not returning a huge amount of data each time.
 
Yeah, been looking at other games that run in a similar way to mine. I just need to engineer the way I had been building it - at the moment I have been loading a load of data each team even if nothing changes. I need to shift some of the processing on to the client as opposed to getting the server to render the pages to be displayed.

Back to the code...
 
Yeah, been looking at other games that run in a similar way to mine. I just need to engineer the way I had been building it - at the moment I have been loading a load of data each team even if nothing changes. I need to shift some of the processing on to the client as opposed to getting the server to render the pages to be displayed.

Back to the code...

Yep id def try and do as much processing as possible in the javascript callback function rather than processing and sending back already rendered pages. Let us know how you get on :)
 
Back
Top Bottom