Filter games on the profile page #283
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This continues to use Redis for secondary indexing. A
ZSET
is maintained for each player and game state (all, running, won, lost, drawn), scored by insertion time. Anindex with 100,000 games
takes around12 MB
viaMEMORY USAGE
.Advanced lookups, such as games against a specific player, could be implemented by
ZINTERSTORE
the two most selective sets (e.g. player-1:won and player-2:lost, player-1:drawn player-2:drawn) into a short-lived key, then callingZCARD
andZREVRANGE
.Because this is using way more sorted set commands, the performance was tested with the
/deploy/load-test
deployment. 30k req/s over >10 minutes. No hiccups. The StoredEventListener had a parallelism of 1 for each shard. Replaying the whole event stream of a single shard, after having >10 minutes of constant play in the table, took around ~1 1/2 minutes (>10kZSET
and 4kZREM
executions per second). Although this can be speeded up by grouping more Redis commands within a pipeline, or using another indexing technique, e.g. RediSearch, this is fast enough.