šŸš€ Scaling to 93K RPM: Moving Quota Management from SQL to Redis

Published: (January 14, 2026 at 11:41 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

What happened?

Your favorite artist announced an upcoming concert, and customers rushed to buy tickets. The e‑ticketing platform started returning errors and became painfully slow.

The root cause was the database CPU spiking to 100 % because a single ā€œhotā€ row—used to count the quota for the event—was being queried and updated continuously. The table looked like this:

eventIdshowtimeIdquotareserved
1115,00010,000

Each request read and wrote this row, causing lock contention and exhausting CPU resources.

The solution

Moving the quota counter to Redis

Redis stores data in RAM, offering far lower latency than disk‑based databases. A naĆÆve implementation might look like this:

function reserveTicket(showtimeId, amount) {
    const reserved = parseInt(redis.get('{key}'));
    if (reserved  {
        // …order creation logic…
        const result = await redis.eval(reserveLuaScript, {
            keys: ['{key}'],
            arguments: [String(amount), String(quota)],
        });
        if (result !== 1) {
            throw error('reservation failed');
        }
    });
    // …other logic…
}

Persisting the count back to the database

Because Redis is a cache, the authoritative source of truth remains the relational database. A background worker polls Redis every 5 seconds and writes the current count back to the DB, providing eventual consistency without sacrificing performance.

Result

  • Orders per minute increased from 5,000 to 93,240.
  • Database load dropped dramatically, eliminating the CPU bottleneck.
  • The system now handles peak ticket‑selling traffic reliably.

Key takeaways

  • Diagnose the real cause of performance problems; in this case, a hot row caused DB lock contention.
  • Align system design with actual usage patterns—hot rows need special handling in high‑throughput scenarios.
  • Use Redis (or another in‑memory store) with atomic Lua scripts to manage counters safely.
  • Keep the relational database as the source of truth and synchronize it asynchronously for durability.
Back to Blog

Related posts

Read more Ā»

Rapg: TUI-based Secret Manager

We've all been there. You join a new project, and the first thing you hear is: > 'Check the pinned message in Slack for the .env file.' Or you have several .env...

Technology is an Enabler, not a Saviour

Why clarity of thinking matters more than the tools you use Technology is often treated as a magic switch—flip it on, and everything improves. New software, pl...