[erlang-questions] How would you do it?

dmitry kolesnikov <>
Mon Jul 2 14:43:49 CEST 2012


You have to split your data structure. The player profile has to go into
hash table (e.g. Ets)  and ranking into separate index. It should give you
better performance since your player profile is big. The first candidate
for index is gb_trees. It should be good enough to cover 3.1 but 3.2
requires a range search, which is available in my Branch of gbt (
If you are not fine with gbt performance then you have to shard your scores
into multiple trees.

Best Regards,
Dmitry >-|-|-*>

On 2.7.2012, at 13.30, Max Bourinov <> wrote:

Hi Erlangers,

I need to build a ranking system for online game.

I think I will have a ranking gen_server that will accept cast messages
like this: {score, Player :: profile(), Score :: integer()}.

So, the question is what would be most appropriate data structure if:

   1. I have to rank about 50 000 - 100 000 different players.
   2. On each score message I have to re-sort whole ranking table.
   3. It must be very cheap to get:
      1. top 100 players
      2. player's rating +/- 10 players about current player
   4. I expect about 20-50 score messages per seconds
   5. Size of score message is about 4KB (profile takes most of the space).

Any ideas or suggestions are welcome!

Best regards,

erlang-questions mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120702/e78befc9/attachment.html>

More information about the erlang-questions mailing list