Search code examples
solrrankingriakleaderboard

Modelling a leaderboard/ranking list in Riak


I am currently researching databases for a scalable game backend. Riak looks very nice from an operational point of view. I can easily see how to model user and game data and statistics in Riak. But I have trouble with leaderboards/ranking lists.

Assuming we have millions of players and the ranking would be based on a single highscore integer, what would be the "best" way to store ranking lists? We would need to get the individual rank of a player and paginated lists of all players, say ranks 1-100 or 14500-14600. The score would be updated frequently and the player's rank should update in real time.

Map/Reduce should work, but I guess it would be a little heavy for real time results. I might be completely off here, as I have not done any benchmarks.

What about Riak Search? I don't know Solr at all, so there might be a way to do it, that I missed completely from reading the docs.

This blog post uses a set of sets approach. Coming from a Basho engineer, it's most likely a good solution. But is it the only feasible way to it in Riak? Can we do something a little more "elegant"?

Thanks for your time!


Solution

  • Riak search (Solr) may seem a natural choice for at least some of your use cases. It supports sorting (by highest score) and pagination. However, according to Basho, Riak search should not be used when deep pagination is needed. It also does not scale well beyond 8-10 nodes. Also from my experience there can be a significant delay between storing a value and its becoming fully indexed in Solr, which probably does not meet your real time requirement. So all in all the solution suggested in the blog post seems right.