Jump to content

php output cache every 2 seconds


quarky

Recommended Posts

I'm building a multi-player flash game with a live leaderboard. Players play simultaneously and their ongoing scores will be posted to a mysql db every 2 or so seconds. The leaderboard will display the top X players "live" - and so will also need to refresh every 2 or so seconds.

 

I'm trying to think how to build it for optimum performance. I'm thinking of displaying the leaderboard inside the flash (instead of on the webpage) which would mean me setting up the flash game to reload a php file that queries the database every 2 seconds. However, a few hundred simultaneous players would mean a lot of redundant calls to the database. How can I set up the php output or mysql output to cache for 2 seconds? How would you go about building this for optimal performance???

 

Thanks

Quarky

Link to comment
Share on other sites

The first thing that has occured to me is

1) At what point do you record scores? End of level? Time period? End of game?

 

Personally I wouldn't use a time period to send scores to your database, and instead would capture them at particular points. This will reduce the number of writes to your database (as they're the expensive part).

If you're presenting the scores to users of your game then I would probably just use a web page and when it is refreshed (or loaded) just present the leader board.

 

I think there is limited user experience in presenting "live" updates every 2 seconds. If people want to see how they're doing then make them refresh the board (page) at their leisure.

 

Bear in mind that a read of a large dataset is going to become a more and more expensive operation as the user list grows, thus keeping it limited (i.e. at user refresh rather than timer) will help to reduce the load you experience.

Link to comment
Share on other sites

dont mean to be rube but why flash i no it looks good but it so inoyeing

i got a friend who provides chess with flash and he got every server dedecated for high proformence, when there lots off playes more then 20 playing at once the laging with flah really pee him off.... trust me flash looks good but proformence wise is crap.......

 

the only way foward is have deeadecated servers........... example database server php server flash server high bandwidth cost loads nice idear but exspenceve.......

Link to comment
Share on other sites

Thanks for your replies.

uniflare, wow! thanks a lot. I'll need to study your solution a bit - some of the php went over my head...

 

aschk, the posts to the database are sent by the users and not according to a schedule. My estimates were that each user would be posting every 2 seconds or so...

 

Thanks all for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.