1

We want to give rankings to the user depending on their points. How we should implement this in real time with DynamoDB. we might have more than 10000 users sorting and querying over 10000 scores to find the rank seems to be expensive. Please give some suggestions.

Prithivi Raj
  • 2,658
  • 1
  • 19
  • 34
  • Go through http://simondlr.com/post/26360955465/dynamodb-is-awesome-but however, i'd suggest having a pipeline from dynamodb to elasticsearch or rdbms and use that for your analytical works – hjpotter92 Jan 05 '18 at 13:31
  • Thank you. I will check the links and let you know. – Prithivi Raj Jan 05 '18 at 13:36
  • There are good documentation on Amazon on how to deal with cases like this so I suggest you check those out before asking here. – kometen Jan 08 '18 at 13:34

2 Answers2

0

If you keep the user's rank as the table's sort key, pretty much all your use cases would be efficient e.g. you can search in a rank range, get ranks in paginated views etc.

Vishal Raja
  • 303
  • 1
  • 8
0

All tables have a partition key (probably userId), but when you ad a sort key, you can get items in an ascending or descending order for that sort key.

When you query (nodejs documentation), you can add the ScanIndexForward <Boolean> parameter to your request, which allows you to sort in ascending/descending order. If you are worried about consuming too much capacity, also add the Limit <Int> parameter to your query.

If your current sort key is not set to rank, set up a Global Secondary Index instead with rank as the sort key.

Daniel Apt
  • 2,468
  • 1
  • 21
  • 34