The Desi Architect
Notes / Docker Sandboxes / Real-Time Leaderboard with Redis Sorted Sets
Docker Sandboxes · Tier 2: Data & Scale · Lab 22

Real-Time Leaderboard with Redis Sorted Sets

Build a real-time fantasy gaming leaderboard (Dream11 and IPL scale) using Redis Sorted Sets. Discover why skiplist indexes give sub-millisecond O(log N) rank seeks, how atomic ZINCRBY prevents lost updates during live matches, and how fractional timestamps solve the equal-score tie-breaking trap.

Time30 minutes
StackRedis 7Ports 16408
MemoryAbout 60 MB
Before thisLab 06Redis Basics
Verified runWindows, Mac, LinuxBash and PowerShell
  1. 1PrepareWhat you will learn
  2. 2PredictGuess before you run
  3. 3RunStep by step
  4. 4ObserveWhat you should see
  5. 5Break itChange one thing
  6. 6Clean upLeave nothing running
On this page
  1. 00 / What You Will Learn
  2. 01 / Why It Matters
  3. 02 / What We Are Building
  4. 03 / Words You Need
  5. 04 / Predict First
  6. 05 / Step by Step
  7. 06 / What You Should See
  8. 07 / Look Inside
  9. 08 / Break It, Fix It
  10. 09 / In Real Projects
  11. 10 / Interview Corner
  12. 11 / Clean Up

00 /What You Will Learn

By the end you will be able to
  • Understand how Redis Sorted Sets combine a Hash Table and a SkipList for O(log N) rank operations.
  • Query Top 10 and player ranks across 100,000 users in under 2 milliseconds.
  • Render an "Around Me" relative leaderboard window for mobile apps without scanning the full set.
  • Mutate player points atomically with ZINCRBY without database lock contention.
  • Solve the equal-score tie-breaking dilemma using fractional timestamp scoring.
  • Safely delete multi-megabyte big keys using asynchronous UNLINK instead of blocking DEL.

Before you start

Finish Lab 05 (Redis Basics: Core Commands and Data Structures) first. You should know what keys, hashes, and basic string operations are. Docker Desktop must be running.