The use case:
We've got 500 million players of a videogame in a MongoDB collection playerProfiles
. Each document has several properties like wins
or kills
. Now we'd like to create a leaderboard for these properties so that we can figure out each player's rank for wins
or kills
.
For the Top 100 leaderboard I would simply sort the collection by one of these properties and cache the result for let's say 5 minutes in redis. What I am struggling with is how I can make this work for all player profiles.
The question:
How should I get every player's rankings for wins
or kills
so that it doesn't overwhelm the database server? If it makes sense I am free to use other database systems to solve this issue.
My idea:
My first idea was to create an own mongodb collection which only contains the player's id and it's rankings for kills
and wins
. I would then regularly update this collection. But even updating this collection of 500m player profiles should take a significant time. Is there a better approach for this type of problem?