AWS Builder Center
Designing a Fair, Capacity-Aware Virtual Waiting Room for 10 Million Fans on Amazon DynamoDB

Designing a Fair, Capacity-Aware Virtual Waiting Room for 10 Million Fans on Amazon DynamoDB

A submission writeup for DynamoDB Data Modeling Challenge #1

Architect of invisible things that keep visible things alive.

The problem in one sentence

Tickets go on sale, a million-plus fans hit "buy" in the same few seconds, and DynamoDB has neither a global sort order nor an auto-incrementing counter to fall back on — so fairness has to be engineered, not assumed.
That constraint is what makes this challenge interesting. It would be trivial to build a waiting room on a relational database with a single  ORDER BY arrival_time  query and a global sequence. DynamoDB gives up both of those conveniences in exchange for horizontal scale, and the entire design problem is recovering the feeling of a single ordered line without ever paying for a single point of contention.

Starting point: where a naive design breaks

The obvious first attempt is one table, one partition key per event, and a  PutItem  per fan as they arrive. That fails immediately — every DynamoDB partition has a practical write ceiling (roughly 1,000 WCU) regardless of billing mode, and a single  EventId  key puts every one of 10 million arrivals on that same partition. Adaptive capacity helps redistribute load across existing hot partitions, but it operates on the order of minutes; a burst that needs full throughput in the first second doesn't have minutes to wait for it to kick in.
The second obvious attempt — give every fan a real position with  queuePosition = atomicCounter + 1  — fails for the identical reason. It just relocates the hot partition from the queue table onto a single counter item.
Both failures point at the same underlying rule: any mechanism that requires a single item to see every write, at this scale, is disqualified before it's evaluated on correctness. Everything in the final design follows from taking that rule seriously.

The architecture

Fans → Edge (CloudFront + WAF) → Arrival API + Kinesis buffer → Sharded queue table (DynamoDB)
│
DynamoDB Streams
│
Position resolver (windowed merge) → Capacity controller → Promotion engine → FanState table + WebSocket → Fans
Three DynamoDB tables carry this, chosen by testing each pair of entities against one question: do they have high access correlation and similar operational characteristics, or independent ones? That's the actual decision rule behind single-table vs. multi-table design — not a blanket preference for one over the other.
  •  WaitingRoomQueue  — write-hot, millions of items, bursty. Partitioned by  EVENT#<id>#SHARD#<n> , so the arrival burst lands across hundreds of partitions in parallel instead of one.
  •  FanState  — one item per fan, read-hot. Status, exact position, ETA, and WebSocket connection ID all live in a single item, because they're always read and written together — the correct trigger for embedding rather than splitting.
  •  Counters  — a handful of items tracking active purchaser capacity, updated a few times per second. Kept structurally separate from the queue table specifically because its access pattern and operational profile have nothing in common with a table absorbing a multi-million-write stampede; merging them would couple their CloudWatch metrics and throttle behavior at exactly the moment isolating blast radius matters most.

The part that actually needed solving: exact, verifiable position

The challenge is explicit that a queue position has to be verifiable — not a vibe, a real number a fan can be told and an auditor can reconstruct. Given the hot-partition constraint above, that number can't come from one synchronous global counter. The design instead assigns it in two stages.
At arrival, an atomic  UpdateItem ADD  against a small per-shard counter item gives each fan an exact, gap-free sequence number — but scoped to their shard only. Because arrivals are spread across N shards, no single item ever sees more than a fraction of total throughput, so this step never throttles.
Shortly after arrival, a resolver running on a fixed ~200ms cadence (triggered by DynamoDB Streams batches) merge-sorts that window's new arrivals across every shard by server-stamped arrival time, recovering true global order. Each fan's exact  queuePosition  is  globalOffset + windowLocalRank , where  globalOffset  is a single counter incremented once per window — roughly five times a second — rather than once per fan. That write rate sits nowhere near a partition's ceiling.
The honest trade-off: there's a bounded resolution lag, typically under a second, between a fan's arrival and their exact position landing.  FanState  carries a shard-local provisional estimate in that gap, which converges to the exact number once resolved. Stating that lag plainly turned out to matter more for the review than hiding it would have — a design that's precise about its own limits reads as more credible than one that implies instant global consistency it can't actually deliver.

Enforcing capacity without a race condition

Promotion runs on a fixed cadence: read available capacity from  Counters , cap the batch size, then select the next batch across shards with a scatter-gather query (each shard's head, merged in the application layer, since there's no cross-partition sort to query directly). The promotion itself is a single  TransactWriteItem  call — flipping each selected fan's status to eligible and incrementing the active-purchaser counter, conditioned on the new total staying under the configured maximum. That condition is what actually prevents overselling; it's enforced by DynamoDB's atomicity guarantee, not by application logic hoping two concurrent Lambda invocations don't collide.

What I'd still want to validate before calling this production-ready

  • Load-test the shard count against a real target arrival rate — the number in the writeup (200–500 shards) is a starting estimate, not a measured optimum.
  • Confirm the ~200ms resolution window holds up under actual DynamoDB Streams batch delivery latency at full burst volume, rather than in isolation.
  • Exercise the failure paths of  TransactWriteItems  explicitly (condition failures, partial contention) rather than assuming the happy path.

Repository

Full design document, access pattern matrix, and an importable NoSQL Workbench data model are here:  github.com/JoseScript7/Foyer 
If you're attempting this challenge yourself, the single most useful exercise was writing the access pattern matrix before finalizing any key schema — every design decision above traces back to a specific row in that table, not the other way around.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article