Data
Moving 100M+ players onto real-time stats
Replacing CubeCraft's end-of-game stats with stats saved as they're earned, and migrating more than 100 million players' stats onto the new system.
- 100M+players' stats migrated
- ~30 sfrom earning a stat to seeing it, was end of game
- ~20xfresher leaderboards, which updated every ~10 min
- 99%+migrated cleanly on the first pass
The problem
CubeCraft’s old stats system only saved a player’s stats when their game ended. If the game crashed, those stats were gone. Leaderboards only refreshed every 10 minutes or so, and newer features like achievements and progression need to know about a stat the moment it’s earned.
What I built
- A new stats system that saves stats almost right away after they’re earned, whether that’s a kill, a win or a block walked, so they reach the menus and every leaderboard in about 30 seconds
- A migration of every player’s existing stats onto it, which is more than 100 million players
- A drift check that flagged anyone whose numbers moved a lot in the move (think “I lost thousands of wins”), and a re-run for every migration that failed or drifted
The first pass migrated more than 99% of players cleanly. The rest, about 1%, failed for ordinary reasons like lag, bad old data or a crash at the wrong moment. At this scale that was still more than a million people, so the re-processing mattered as much as the main run.
- Old statssaved at game end
- Migrateevery player, in batches
- Drift checkflag big differences
- Re-runfailed and drifted players
- Livestats in ~30 s
The migration, as a sketch
for batch in players.in_batches():
for player in batch:
try:
old = legacy_stats.load(player)
new = convert(old)
stats.write(player, new)
if drift(old, new) > THRESHOLD: # "I lost thousands of wins"
retry_queue.add(player, reason = "drift")
except error:
retry_queue.add(player, reason = error)
for player in retry_queue: # ~1% of players, still over a million people
reprocess(player)
# afterwards, live
on stat_earned(player, stat, amount):
stats.increment(player, stat, amount) # saved now, not at game end
leaderboards.reflect(player, stat) # visible in about 30 seconds
Why it matters
Players don’t lose progress when a game crashes, leaderboards keep up with what’s happening, and achievements and progression finally have stats they can react to as they happen.