Menu

1 / 2

Building a Leaderboard for a Game Site with SQLite: 3 Traps I Hit with Concurrent Score Submissions

DEV Community: nextjs·no momo·about 19 hours ago
#7gkT3UFo
#devtonextjs#devto#dev#score#leaderboard
Reading 0:00
15s threshold

After static JSON couldn't handle scores anymore, I added a Node.js + Express + SQLite backend. On day one, I ran into scores being overwritten, same-score rankings jumping around, and the leaderboard disagreeing with the database.

The root cause wasn't SQLite's performance. It was that I didn't understand SQLite's concurrent write model . Here's the debugging process and fix for all three traps, plus a framework for deciding what to use at each stage.

Environment

Node.js 20.11 + Express 4.18 + better-sqlite3 11.3

Test devices: MacBook Pro M1 (local load testing), Vercel Serverless (production)

Tools: autocannon concurrent load testing, SQLite .timer on query timing

Why I Moved from Static JSON to a Backend

In the first article, the MVP stored scores in localStorage , which meant they disappeared when you switched devices.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.