Share this chat
Anyone with the link can view this conversation.
For the Milka game I'll have 2,500 to 3,000 players loading a live leaderboard at the same time, mostly during the lunch and coffee-break traffic spikes. I don't want every page load to run a DB query that ranks all the form responses. How do I keep the leaderboard live without overloading the database?
Quick question before I over-engineer this: can you accept a cached leaderboard? The data would be a few seconds out of date, but in exchange the database would barely be queried.
A cache is fine in principle, but I want it to feel dynamic: when a player answers, they should see their own position move, not wait for a refresh.
Then do both: a cached ranking for everyone, and an optimistic local update for the player who just answered.
- Refresh the cache on a timer, not on requests. Recompute the full leaderboard every 30 seconds in the background and serve that result. No page load ever triggers a recomputation, nobody ever hits an empty cache, and the database gets one query every 30 seconds instead of thousands.
- Simulate the rank change locally when a player answers. As soon as a player submits an answer, update their cached score and move them to their estimated position right away, so the feedback feels instant.
- Let the real ranking catch up. On the next 30-second refresh, their real rank replaces the estimate, computed against everyone else's latest answers.
Each player gets instant, believable feedback, while the real ranking stays cheap to compute and consistent for all 3,000.
Amazing, that's exactly the feel I wanted.
Send an email to Eliott
Write your message here and it will open in your email app.
Eliott Baylot's curriculum vitae
Downloadable PDF document.
Eliott's CV
Mind introducing yourself?
Just so Eliott knows who he's talking to. Only your name is required.
Claude is an AI and can make does make mistakes. Please triple-check responses.