TL;DR: A live leaderboard is not a sorted list with a refresh button. It is a small real-time system with five decisions you have to make on purpose: who is allowed to write a score (only the backend), how ranks and ties are defined (in writing, before launch), which time window the board covers (and in which time zone), how clients get updates (push a version, let them fetch, and reconcile on reconnect), and what happens when a score is wrong (corrections are normal, so design for them). Get those right and the board stays fast and trusted. Skip them and you get two phones showing two different winners, which is the one failure a leaderboard cannot survive.
At RAQTS, where I lead engineering as CTO, the product is a sports-tech platform that connects players and facilities. It spans a Unity interactive layer called Lumo, React Native mobile apps, and a Next.js web portal, and live leaderboards tie them together. This post is the engineering detail: how I build a leaderboard that many screens watch at once, on any stack.
Why "just sort the scores" breaks
The first version of every leaderboard is a database query: select scores, order by points, limit 50. It works in the demo. It starts failing the moment three things are true at the same time: scores change while people watch, people watch on more than one kind of device, and someone cares who is in first place.
The failures look like this:
- Two screens disagree. The phone cached a board from 20 seconds ago, the facility screen just refreshed. A player sees themselves in second, their friend sees them in third. Trust is gone, even though both screens showed data that was correct at some moment.
- Ties get resolved by accident. Two players on the same points appear in whatever order the database returned them, and that order changes between requests. Positions flicker.
- "This week" means different things. The server thinks the week started Monday in UTC, the facility is in California, and Sunday evening scores land in the wrong week.
- A wrong score has no fix path. The only correction tool is a hand-edited row that skips every cache.
None of these are UI problems. They are data and systems problems, and they are cheaper to design out than to patch.
Decision 1: only the backend writes scores
The rule I hold on every project with a ranking: clients submit events, the backend decides scores. A Unity experience, a mobile app or a portal can report that something happened, a session completed, a result was entered. The server validates it, computes the points, writes the score, and is the only thing that ever says what someone's rank is.
Three reasons:
- Consistency. If each client computes rank from its own partial view, they will disagree. One authority means one answer.
- Cheating and mistakes. Anything a client can write directly, a modified client can write too. Even without bad actors, buggy old app versions in the wild will send bad data, which I covered in keeping a mobile backend compatible with old app versions.
- Auditability. If every score change is an event with who, what and when, you can rebuild the board from history and answer "why did my rank drop?" with facts.
In practice that means a score submission endpoint that is idempotent (a retried request on a flaky mobile connection must not count twice), validates against rules the server owns, and appends to a score history before updating the current standings.
Decision 2: define ranks and ties in writing
Before writing ranking code, I write the ranking rules as a short spec and get the founder to agree to it. It is usually one paragraph, and it saves weeks of "that looks wrong" later. The questions:
- What is the score? Total points, best single result, average, a rating? Averages need a minimum number of sessions, or one lucky first session tops the board.
- How are ties ranked? The common options are shared rank ("1, 2, 2, 4"), dense rank ("1, 2, 2, 3"), or a tie-breaker. If you use a tie-breaker, pick one people accept as fair, such as whoever reached the score first, and make it deterministic so the order never flickers between requests.
- Who appears? Hidden or deleted accounts, test users, staff accounts, players who opted out. Each one is a filter you will need eventually.
Decision 3: pick the windows and time zones up front
Most products want more than one board: today, this week, this season, all time, per facility, per friend group. Each is a separate slice, and each needs a precise definition of when it starts and ends.
My defaults:
- Windows are anchored to the place the competition lives in. A weekly board for a facility resets at midnight in that facility's time zone, not the server's. Store the zone with the facility, not in a config file.
- Closed windows are frozen. When a week ends, snapshot the final standings and stop recomputing them. Winners of last week should not change because a late correction arrived three days later, unless the rules say so.
- Every window is a key, not a query. Rather than recomputing "this week" from raw history on every read, keep a precomputed standings structure per window and update it on each write.
For that last point, a sorted set in Redis is the classic tool, and Redis is part of the stack I reach for regularly. Each window is one sorted set keyed like board:facility:{id}:week:{yyyy-ww}, the member is the player and the score is the points. Reading the top 50, or a single player's rank, or the five players around them, is a fast lookup instead of a sort. If the stack is already on Firebase or Postgres, the same idea works with a standings table updated on write and indexed on score. The data store matters less than the principle: compute rank when scores change, not every time someone looks.
Decision 4: how clients stay in sync
"Live" sets an expectation of seconds, not minutes. But pushing the full board to every connected client on every score change is wasteful and fragile. The pattern I prefer is simpler:
- Each board has a version number that increments on every change.
- The server pushes a small notification ("board X is now version 1042") over whatever real-time channel the stack has: WebSockets, Firebase's real-time listeners, or server-sent events for the web.
- The client fetches the board when it sees a version newer than the one it has, and ignores notifications about versions it already has.
- On reconnect, the client always refetches and compares versions, because it cannot know what it missed while the phone was in a tunnel or the app was in the background.
This keeps the push messages tiny, makes missed messages harmless, and gives every client the same converge-to-latest behaviour. With real-time off, a fetch on open gives the same answer, just later: it degrades to slow, not wrong.
Two details that matter on mobile and in Unity:
- Throttle redraws. If ten scores land in two seconds, the client should animate to the final order once, not reshuffle ten times. Players read movement as meaning.
- Show the player's own row even if it is not in the top 50. "You are 312th, up 14 this week" is the row most people actually look at. Fetch it separately with the player's rank and neighbours.
Decision 5: corrections are normal, design for them
On a real sports product, scores are entered by people and devices, and some will be wrong. The question is not whether you will need corrections but whether they are a clean operation or a database edit at midnight.
What a correction needs:
- A correction event, not an overwrite. Record the original, the change, who made it and why. The current score is derived from the history.
- One code path for updates. A correction should flow through the same write path as a normal score, so every affected window, cache and version number updates together. Hand-edited rows are how you end up with a board that is fixed on the portal and wrong on phones.
- Rules for closed windows. Decide whether a correction to last week changes last week's frozen result. Usually it should for honest mistakes reported quickly and should not after a cut-off, and the facility should know which.
- A rebuild script. If you keep score history, you can recompute any board from scratch. I write that script on day one and run it in staging regularly, because the day you need it is the day something is already on fire. It pairs well with a kill switch for the live updates so you can freeze a board while you fix it.
What I test before a leaderboard ships
A leaderboard looks finished long before it is. Before launch I check:
- Ties: two, three and ten players on identical scores show in the same order on every client and every refresh.
- Window edges: a score submitted one minute before and one minute after the reset, in the facility's time zone, lands in the right week.
- Duplicates: the same submission sent twice (simulate a retry) counts once.
- Reconnects: a client offline during five updates shows the correct board within seconds of reconnecting.
- Old app versions: the oldest supported build still renders the board without crashing when the server adds a field.
- Corrections: changing one score updates the top list, the player's own row, and every other window it belongs to.
- Load: a burst of score submissions at the end of a session, which is exactly when everyone is also looking at the board.
Backend checks are cheap to automate; the client ones are a short pass on real devices, the same mindset as error monitoring for a small product: you want to know about a broken board before the facility does.
The short version
A trustworthy live leaderboard comes down to a few rules: the server is the only writer, ranks and ties are defined in plain words, windows follow the venue's clock, clients converge on a versioned board instead of trusting push messages, and corrections run through the same path as everything else. It is a few extra days of work up front, and it is what lets a room full of players and a facility manager look at different screens and agree on who is winning.
If you are earlier in the product journey, the leaderboard is often also your activation moment: seeing your name on the board is when a lot of players decide the app is for them. That is one more reason to make it right.
I lead engineering as a fractional CTO and build cross-platform products across Unity, React Native, Next.js and real-time backends, along with production AI agents, for startups in the US, UK and Europe. If you are building something where many people watch the same live data and it has to be right, read more about my background or book a call.