← Back to Writing

How Do Online Games Update Leaderboards So Fast? — Redis Sorted Sets

·5 min read
RedisSystem DesignBackend EngineeringData Structures
How Do Online Games Update Leaderboards So Fast? — Redis Sorted Sets

"How do online games update leaderboards so fast?" A friend got this question in an interview last week. It stayed in my head all weekend.

The short answer: Redis Sorted Sets (ZSETs).

Where You See Them Everywhere

  • Competitive coding platforms (LeetCode contests)
  • Gaming leaderboards
  • Trending music charts or tweets
  • Anywhere ranks need to update instantly

Building Something Real

Instead of just reading about it, I decided to build something real. At Cars24, we have a 60-day fitness challenge. People log daily scores for a challenge of the day — pushups in 60 secs, squats in 60 seconds.

I thought — a real-time leaderboard would actually motivate people. So I built one.

  • Submit your score → Your rank updates instantly
  • Top 10 refreshes in real-time
  • Your position shows up in milliseconds

What Powered It?

Redis Sorted Sets. No complex SQL queries. No extra caching layers. Just Redis commands like ZADD, ZRANGE, ZRANK.

Real-time Leaderboard Demo
The fitness challenge leaderboard in action

How Simple It Was

I always thought leaderboards were complex. Turns out, choosing the right tool solves most of the problem.

Extra Features

  • Personal score history
  • Admin controls for daily challenges
  • Score moderation (because people get creative)

What are other real-world use cases of Redis Sorted Sets you've seen or built?