Escrow
Seats are grouped in blocks. Each block has exactly one owning region per epoch. Any region accepts any buyer; a hold on the other region’s block is forwarded to its owner.
AWS · Mumbai + Hyderabad · DynamoDB global tables
Seatlock is a flash-sale ticketing backend that takes bookings in two AWS regions at once and keeps selling when one of them dies mid-sale. Every number on this page was measured on the live system.
Sell 1,000 seats to 6,000 people arriving in the same 30 seconds, from two regions at once, so buyers on either side get fast writes and the sale survives a region outage. DynamoDB global tables replicate asynchronously and settle conflicts with last writer wins: two regions can both sell the last seat before either write arrives at the other.
Seats are grouped in blocks. Each block has exactly one owning region per epoch. Any region accepts any buyer; a hold on the other region’s block is forwarded to its owner.
Each region renews a lease every 4 s at a small table in a third region (Singapore). Takeover is a compare-and-set there, so a network split can never produce two owners.
Before every seat write a region checks its own lease on its own clock. If it can’t renew, or its own API stops answering, it stops writing before the peer is allowed to take over.
A buyer is told “confirmed” only once the other region’s replica shows the seat SOLD. Anything a buyer was promised is visible to a survivor before it takes over.
A recorded drill, second by second: 15 buyers per second for 4 minutes on a 3,000-seat sale, both regions selling. At 45 s every Mumbai function is cut off. This replay is built only from the load generators’ records and a 1 Hz watcher.
| Design | Tickets for 1,000 seats | Seat sold twice | Time to ticket p50 / p99 | Cost / 1M bookings |
|---|---|---|---|---|
| B1 single region | 1,000 | no | 2.2 / 2.6 s | $258 |
| B2 two regions, naive | 1,099 | yes | 2.3 / 2.9 s | $225 |
| B3 DynamoDB MRSC¹ | 1,000 | no | 0.3 / 1.4 s¹ | $118¹ |
| B4 Seatlock, two regions | 1,000 | no | 4.8 / 11.0 s | $324 |
¹ Seat claim only: no queue, payment or confirm. MRSC can’t include Hyderabad, has no transactions or TTL, and puts Singapore in every write’s path. The trade-off is honest: two-region safety costs about 2.6 s per ticket and 26 % per booking over one region.
| Drill | What was done | Seats sold twice |
|---|---|---|
| Region kill ×3 | All Mumbai functions cut off mid-sale, then restored and handed back | 0 |
| Clock skew ×3 | Mumbai cut off from the witness while still selling, with clocks 30 s off (one case beyond the safety bound) | 0 |
| Replication lag | Every confirm told the other replica is 5 s or 20 s behind | 0 |
| AWS FIS | Real DynamoDB replication into Mumbai paused for 2 minutes | 0 |
| Game day | Lag, skew, a lease cut-off and the FIS pause, all at once | 0 |
| Payment chaos | Every webhook duplicated with new ids, 10 % dropped, lost 504s | 0 double charges |
The drills found 5 real bugs. Each is fixed, written up as a decision record and pinned by a regression test. All results
Cleave, an attack-path scanner I built, found that CDK’s default bootstrap made every deploy role admin-equivalent. Deploys now run as a scoped role, and every role carries a permissions boundary.
5 certain paths to admin → 0