Back to case studies
Node.jsExpert

Implementing a real-time leaderboard with sorted sets in Redis

Scenario

Context A gaming platform must display a live leaderboard of the top 100 players, updated in real-time as scores change. The Problem The current implementation runs a full table scan and sort on the database on every page load, becoming unacceptably slow at 1 million players. Constraints Store player scores in a Redis Sorted Set using ZADD. Retrieve the top 100 with ZREVRANGE with scores. Update scores atomically with ZINCRBY. Push leaderboard updates to connected clients via WebSocket when the top 100 changes. Expected Deliverable A Node.js real-time leaderboard using Redis Sorted Sets for O(log N) score updates, with WebSocket-based live push to clients when rankings change.

Targeted skills

nodejsredissorted-setsleaderboardwebsocket
    Implementing a real-time leaderboard with sorted sets in Redis — Node.js hands-on scenario | CodeDuel