← All work

Non-profit institution, lead backend engineer, GCP

The click day that can't oversell

A time-boxed "click day": thousands of users competing for fixed-capacity slots, traffic spiking on the same seats in the same second, one hard invariant: never exceed capacity.

700k+user journeys in one 60-min run
0seats oversold, proven by DB query
0%error rate at 2,000 concurrent users
49-170 msp95 latency under full load

The challenge

In a competitive enrollment event there are two ways to fail, and both are fatal: oversell a seat and you break a promise to a real person; go down under load and the event itself fails publicly. The system had to absorb the spike, stay fair, and be provably correct.

Architecture

The hot path never waits on SQL; SQL never trusts Redis blindly.

What made it work

  • Redis-first reservation: a Lua token bucket as the primary path: atomic and fast under contention.
  • Graceful fallback: a circuit breaker switches to a transactional SQL row-lock path when Redis is down, and an expired-block sweeper cleans up abandoned reservations.
  • Self-healing state: a leader-elected 60-second reconciliation realigns Redis counters against the database, acting only on drift confirmed twice in a row.
  • Contract-grade verification: a client-signed test plan, a k6 suite with unit-tested helpers, monitoring dashboards and an operational runbook.
  • Failure tested on purpose: a Redis failover deliberately induced mid-test caused no measurable degradation.
  • Bottleneck found by measurement: a multi-VM load fleet isolated the breaking point at 6-7k concurrent users; a single-variable A/B proved the database tier (not the app) was what to scale.

Outcome

The event ran on Cloud Run, Cloud SQL and Memorystore, all defined in Terraform, with one-flag pre-event scaling. In the target load run (2,000 concurrent users for a full hour, 700k+ complete journeys), the most contested seats filled exactly to capacity, verified by direct database query. Zero oversold, zero errors.

Need to take an idea all the way to a product that holds up under real load? See how I work in the Idea to product offer.

A project like this one? Write me a couple of lines: I'll tell you where I would start.

Get in touch Book 30 minutes

emanuel@riverdevstudio.it

I reply myself, within one working day.