Open source · ap-south-1 + ap-south-2

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.

1,000 seats · 20 blocks of 50Illustrative animation
Both regions selling their own blocks
MumbaiHyderabadTakeover
sold 0 / 1,000 · twice 0
0
seats sold twice, in every storm and every drill
26–34 s
until the surviving region sells the dead region’s seats
1,000 / 1,000
tickets for 1,000 seats with two regions selling
$324
per million bookings, in a 6× oversubscribed storm
Replays use recorded data, so this page works with the demo backend hibernated. Redeploy takes ~45 min from the runbook.
In 24 seconds

Two phones. One last seat.

01 · The problem

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.

Naive two-region · illustrative buyers
Mumbai
seat 1000
free
·
Hyderabad
seat 1000
free

Press the button: two buyers (illustrative) try for the last seat, one in each region.

Tickets sold for 1,000 seats · same storm, 4 designs, medians of 3 runs
B1 single region
1,000
B2 naive two-region
1,099
B3 multi-Region strong¹
1,000
B4 Seatlock
1,000

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.

02 · The mechanism

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.

Mumbaiap-south-1
selling
lease
WitnessSingapore · ap-southeast-1
epoch 1leases: MUM ✓ HYD ✓
Holds leases, never sells. Takeover is a compare-and-set here.
Hyderabadap-south-2
selling
lease
blocks 01–10 start with Mumbai, 11–20 with Hyderabad (illustrative split)50 seats per block

03 · Architecture

Tap any part to learn its job.

Edge
Mumbai · sells
Singapore · witness
Payments
⇄ global table replication ⇄
Hyderabad · sells

04 · Failover replay · recorded drill 3

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.

0.0s
before the kill
Loading recorded drill…
0 s60120180247 s
Hyderabad’s seats, sold by Hyderabad Mumbai’s seats, sold by Mumbai Mumbai’s seats, sold by Hyderabad (takeover)
0
seats held by Hyderabad
0
seats held by Mumbai
0
Mumbai’s seats held by Hyderabad
0
seats held by both regions after the kill

    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.

    05 · Proof

    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.

    0
    seats sold twice
    in every storm, every region kill, the clock-skew and replication-lag drills, a real AWS FIS replication pause, and a game day with all faults at once.
    One storm, four designs
    1,000 seats, ~6,200 buyers (0 → 250 buyers/s over 10 s, held 20 s), 3 runs each, medians.
    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.

    Faults injected, and what happened
    Region kill ×30 twice
    Every Mumbai function cut off mid-sale, then restored and handed back. RTO 26–34 s across the kill drills and game day.
    Clock skew S1–S30 twice
    Mumbai cut off from the witness while still selling: takeover sale at 22–23 s. With a 30 s skew inside Mumbai, it sold 15 seats after losing its slot: 11 refunded, 4 confirmed safely.
    Replication lag0 twice
    Every confirm told the other replica is 5 s / 20 s behind: time to ticket p50 10.2 s / 31.0 s, 0 refunds.
    Real AWS FIS pause0 twice
    Replication into Mumbai paused for 2 minutes. 2,846 paid = 2,846 sold, 0 refunds, 0 dead letters.
    Game day0 twice
    All faults at once. Fence lapsed 15.8 s, slot taken 24.8 s, RTO 26.1 s; 2,156 tickets, 0 seats held by both regions, 36 refunds.
    Payment chaos0 double
    1,000 orders, every webhook duplicated with new ids, 10 % dropped, 10 % declined, 10 % lost 504s → max 1 capture per order.
    Protocol model0 violations
    1,000,000 randomized scenarios: ~250,000 hand-backs, 1.45 million takeovers. It found 2 design bugs before any code shipped.
    Region-kill drills: Mumbai killed mid-sale
    3,000-seat sale, 15 buyers/s. Each drill’s fix is the reason the next one was faster.
    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
    Guarantees, each measured
    G1
    No oversell, including during failover
    Exactly 1,000 for 1,000 seats in every Seatlock benchmark run
    G2
    No seat sold twice
    0 in every storm, region kill (×3), drill, FIS pause and game day
    G3
    No double charge under retries
    Max 1 capture per order in the payment chaos run
    G4
    Every captured payment ends in a ticket or refund
    0 orphans (902 captured = 902 tickets)
    G5
    Unpaid holds return within T + ε
    Released 37.8 s after expiry (budget 70 s; one sample)
    G6
    Fair admission
    Spearman(join time, queue position) = 0.982, 6,587 buyers
    G7
    Survivor sells again after a region loss
    RTO 26–34 s
    G8
    Cost published
    $324 per 1M bookings in a 6× storm; idle ≈ $0 compute
    G9
    No stranded seats when demand is in one region
    90/10 and 100/0 demand splits sold exactly 1,000
    06 · What broke

    5 real bugs. The drills found them.

    Each one is fixed, written up as a decision record and pinned by a regression test.

    Fix
    Continuous watch + one-minute start grace.
    Effect
    Decision record + regression test
    07 · The honest cost

    Two-region safety isn’t free.

    +2.6 s
    per ticket (median) vs one region. Time to ticket p50: 4.8 s vs 2.2 s.
    +26 %
    per booking vs one region: $324 vs $258 per million bookings in a 6× storm.
    Per ticket · Seatlock vs single region
    write units250 vs 214
    read units150 vs 124
    API requests88 vs 66

    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).

    08 · Security

    Five ways to admin. Then none.

    Built in
    • →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.
    Found and fixed · Cleave
    5
    0
    certain paths to admin

    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.

    09 · Run it yourself

    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.

    TypeScriptAWS CDKLambda (ARM64)API Gateway HTTP APIDynamoDB global tablesSQSStep FunctionsEventBridge SchedulerCloudFront + Functions + KeyValueStoreRoute 53Secrets ManagerAWS FISCloudWatch / X-Rayk6GitHub Actions (OIDC)cdk-nag