Model daily game ranking in DynamoDB -


i have question. m pretty new dynamodb have been working on large scale aggregation on sql databases long time.

suppose have table called gamepoints (playerid, gameid, points) , create ranking table rankings (playerid, points) sorted points.

this table needs updated on hourly basis keeping previous version of contents not required. current rankings.

the query give me ranking table (with paging).

the gamepoints table very large on time.

questions:

is best practice schema dynamodb ? how kind of aggregation?

thanks

you can enable dynamodb stream on gamepoints table. can read stream records stream maintain materialized views, including aggregations, rankings table. set streamviewtype=new_image on gamepoints table, , set lambda function consume stream records stream , update points per player using atomic counters (updateitem, hk=player_id, updateexpression="add points #stream_record_points", expressionattributevalues={"#stream_record_points":[put value stream record here.]}). hash key of rankings table still player id, full table scans of rankings table every hour n highest players, or players , sort.

however, considering size of fields (player_id , number of points not take more 100 bytes), in memory cache updated lambda function equally used track descending order list of players , total number of points in real time. finally, if application requires stateful processing of stream records, use kinesis client library combined dynamodb streams kinesis adapter on application server achieve same effect subscribing lambda function stream of gamepoints table.


Comments