Every seat has one owner. Even when a region goes dark.
Seatlock is flash-sale ticketing on AWS. It takes bookings in Mumbai and Hyderabad at once and keeps selling when one of them dies mid-sale. Every number on this page was measured on the live system.
Two phones. One last seat.
Last writer wins. The first buyer loses their seat.
Sell 1,000 seats to ~6,000 people arriving in the same 30 seconds, from two regions at once. DynamoDB global tables replicate asynchronously and settle conflicts with last writer wins: both regions can sell the last seat before either write reaches the other.
Press the button: two buyers (illustrative) try for the last seat, one in each region.
Naive two-region oversold every run: 1,099 (1,089–1,104) tickets for 1,000 seats. Dashed line: 1,000 seats. ¹ Seat claim only, a lower bound; see proof.
Seats held in escrow, each by a single region.
Step through it yourself. Seven moves, from a normal sale to a region dying and getting its seats back.
Tap any part to learn its job.
Mumbai goes offline mid-sale. Hyderabad picks up its seats.
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. Built only from the load generators’ records and a 1 Hz watcher.
Times in the list are seconds after the kill. Orders: 2,700 confirmed, 15 refunded. Refunds are buyers who paid while their seat’s region was going down; the money went back automatically, and no one was told “confirmed” for a seat that wasn’t sold.
Every way it was tried, it held.
A history checker ran on every load test. A randomized protocol model ran 1,000,000 scenarios with crashes, partitions and ±30 s skew: 0 violations across ~250,000 hand-backs and 1.45 million takeovers.
| Design | Tickets for 1,000 seats | Seat sold twice | Hold p50 / p99 | Time to ticket p50 / p99 | Cost / 1M bookings |
|---|---|---|---|---|---|
| B1 single region (Mumbai) | 1,000 | no | 32 / 77 ms | 2.2 / 2.6 s | $258 |
| B2 naive two-region | 1,099 (1,089–1,104) | yes | 36 / 82 ms | 2.3 / 2.9 s | $225 |
| B3 DynamoDB multi-Region strong consistency, seat claim only¹ | 1,000 | no | 92 / 151 ms | 0.3 / 1.4 s¹ | $118¹ |
| B4 Seatlock (Mumbai + Hyderabad) | 1,000 | no | 66 / 184 ms | 4.8 / 11.0 s | $324 |
¹ B3 is the seat claim only (no queue, payment or confirm), so it’s a lower bound, not like-for-like. Strong-consistency tables can’t include Hyderabad, have no transactions or TTL, and put Singapore in every write’s path. Seatlock gets the same guarantee on standard global tables between two Indian regions.
| Drill | Build | Hyderabad takes the slot | RTO | Seats sold twice | Confirmed / refunded |
|---|---|---|---|---|---|
| 1 | Sprint 4 | (invalid: found bug 1) | — | 0 | 2,859 / 6 |
| 2 | + continuous watch | 68 s | 71 s | 0 | 2,432 / 12 |
| 3 | + serving-health gate | 31 s | 34 s | 0 | 2,700 / 15 |
5 real bugs. The drills found them.
Each one is fixed, written up as a decision record and pinned by a regression test.
Two-region safety isn’t free.
Most of the cost pays for the losing buyers: each ticket carries ~5 buyers who queued and didn’t get a seat. A gentler, not-sold-out sale came to ~$79 per million bookings. Idle ≈ $0 compute (no servers).
Five ways to admin. Then none.
- →Separate AWS account under an organization; a service control policy allows only the project’s regions and bans access keys entirely.
- →GitHub Actions deploys over OIDC, pinned to the repo’s immutable id: no long-lived keys exist.
- →One least-privilege role per function; a cdk-nag gate fails the build on findings.
- →Waiting-room tokens checked at the CloudFront edge and again in Lambda.
- →Signed, time-boxed webhooks; duplicates are no-ops.
Cleave, Piyush’s own AWS attack-path scanner, found that CDK’s default setup made every deploy role admin-equivalent. Fixed with a scoped CloudFormation execution policy and a permissions boundary on all 29 roles. Also added: a multi-region CloudTrail trail and EBS encryption by default. Dogfooding found 4 gaps in Cleave itself.
Everything is code.
AWS CDK in TypeScript, deployed by GitHub Actions over OIDC. Runbooks cover deploy-from-scratch (~45 min), teardown, region drill and load test. 16 architecture decision records, 5 of them written after a live storm or drill broke something.