quarky Posted February 18, 2008 Share Posted February 18, 2008 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 Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 i have an answer but the website will not let me post my idea for some reason... i will keep trying Quote Link to comment Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 i have pasted the reply externally: http://www.phpriot.com/92 Quote Link to comment Share on other sites More sharing options...
aschk Posted February 18, 2008 Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 18, 2008 Share Posted February 18, 2008 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....... Quote Link to comment Share on other sites More sharing options...
quarky Posted February 18, 2008 Author Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.