Question

I am writing a simple mobile game at the end of which, the score of the player along with his playerid is uploaded to a database in the cloud. This database maintains the high-scores for every player.

After uploading the score, the game (client app) pulls down all the scores in the database and calculates and displays the percentile scores for the current game, best score for this player, and the best scores for all-time Top 20 players. The problem I have is that currently there are only a few hundred rows in the database but as the size of the database grows, it will be problematic to fetch all the rows and do the computation on the client side.

Is there anyway I can perform this computation in a scalable way with good performance?

Was it helpful?

Solution

You can store each player's absolute score in DB and when ranking is requested find the top score and use that to determine percentage for each player to be displayed. Percentile can be determined by dividing the ordered index of each player by the number of all players registered at the time when you're processing the query's results

All of these should be done in your data access layer on the server (or whatever equivalent you have)

OTHER TIPS

I believe you should make the calculations on the server's side

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top