Section 8: Cutting the Ladder into Rungs - Deep Dive: Ranking Beyond One Node
Executive Summary: One sorted set per board is the right design at 50 million daily players, and Section 3 proved it. Here we multiply the world by ten, to 700,000 ops/s and 50 GB per board, and break it on purpose. Hash sharding spreads writes evenly but sends every rank read to every shard. Score-range sharding with cached bucket counts keeps a global rank at one operation. We pick range sharding and pay for it honestly: a player directory, a cross-shard move protocol that never loses anyone, hot-shard placement, and percentiles for the long tail.
You finish the write-path deep dive feeling good. Then the interviewer pushes back:
"Fine. Now Rift Runners goes viral. Ten times the players. Your one sorted set per board, what happens to it?"
One kind of candidate says "Redis Cluster" and moves on, as if a cluster could split a single key. It can't: one key lives in one hash slot on one node, served by one main thread, and our board is one key. The other kind does the arithmetic first.
The ×10 World, in Numbers
You: "Let me rerun Section 3 at ten times the scale. The weekly board reaches 500M weekly players. The design surge becomes ≈ 350,000 runs/s. Each run does ZADD GT CH plus ZREVRANK on the board, so that's 700,000 ops/s per board. Memory is 500M × 100 B = 50 GB. Both flip triggers for one sorted set per board fire together: more than ~100,000 ops/s, and a board of ~50 GB. Memory I could buy with a bigger box; CPU I can't, because a key is single-threaded. So the real question is what to split the key by."
Interviewer: "Go on. What are the options?"
Two serious ones, plus "approximate ranks only", which we save for the long tail.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson