Seatlock

AWS · Mumbai + Hyderabad · DynamoDB global tables

Two regions sell the same seats.
Neither ever sells one twice.

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.

Live now Mumbai checking… Hyderabad checking…

The problem

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.

Tickets sold for 1,000 seats: single region 1,000; naive two regions 1,099 (oversold); MRSC 1,000; Seatlock 1,000
The same storm against four designs, 3 runs each. Two regions without coordination sold about 100 seats twice, every run.

How it works: one writer per seat

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.

Leases at a witness

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.

Self-fencing

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.

Replicate before confirm

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.

Architecture: CloudFront waiting room, Route 53 latency routing, two selling regions with API Gateway, Lambda, SQS, Step Functions and DynamoDB global table replicas, and a witness table in Singapore

Replay: Mumbai is killed mid-sale

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.

0.0 s
Hyderabad’s seats, sold by Hyderabad Mumbai’s seats, sold by Mumbai Mumbai’s seats, sold by Hyderabad (takeover)
0seats held by Hyderabad
0seats held by Mumbai
0Mumbai’s seats held by Hyderabad
0seats held by both regions after the kill

    Results

    The same storm against four designs

    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.

    Every way we tried to break it

    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

    Security, audited with my own scanner

    Built in

    • Separate AWS account with a region allow-list and a ban on access keys
    • GitHub OIDC deploys: no long-lived keys anywhere
    • One least-privilege role per function; cdk-nag fails the build on findings
    • Waiting-room tokens checked at the CloudFront edge and again in Lambda
    • Signed, time-boxed payment webhooks; duplicates are no-ops

    Found and fixed

    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