SysPadExamples › Real-time gaming leaderboard

Real-time gaming leaderboard

Score submissions go straight into a Redis sorted set (ZADD/ZRANGE/ZRANK) for O(log n) ranking; the database only sees a fraction, for durability.

A sorted set doing the actual ranking work, with the database relegated to an async durability path.

Client Users Load Balancer ALB Leaderboard Service Lambda Leaderboard (Sorted… ElastiCache Score History DynamoDB

How it works

Leaderboard (Sorted Set)
The whole design lives here: ZADD updates a score and ZRANGE/ZRANK read a rank in O(log n), no scan. Both flows hit it - it is the superposition centre, not a cache in front of a slower store.
Score History
Durability only, and only for writes: a copy of each submission lands here off the hot path so the sorted set can be rebuilt if the cache is lost. Reads never touch it.

Request flows

Submit a score

  1. Client
  2. Load Balancer
  3. Leaderboard Service
  4. Leaderboard (Sorted Set)
  5. Score History

Read a rank

  1. Client
  2. Load Balancer
  3. Leaderboard Service
  4. Leaderboard (Sorted Set)

Other interview practice

Open this architecture in SysPad · All examples