#consistency
18 articles
Design a Shopping Cart & Checkout System
Keep a cart consistent across devices, then check out without overselling or double-charging. The available-cart vs consistent-checkout split, inventory holds, and the order saga.
Design an Authorization System (Google Zanzibar / RBAC / ReBAC)
Answer "can user U do action A on resource R?" globally, in milliseconds, consistently. RBAC vs ABAC vs ReBAC, Zanzibar relation tuples, and the new-enemy problem.
Design Ticketmaster (seat booking / reservations)
Sell limited inventory to a stampede of buyers without double-booking a seat. Reservation holds, a conditional-update concurrency guard, and the read-vs-write consistency split.
Design a Globally-Distributed SQL Database (Spanner / CockroachDB)
SQL transactions that are ACID across continents. How Spanner shards into Paxos groups, runs 2PC on top, and uses TrueTime to give you external consistency — the CP counterpart to Dynamo.
Design a Digital Wallet (PayPal / Venmo / Paytm)
Hold balances, transfer money between users instantly, and never lose a cent. Double-entry ledgers, idempotent transfers, and strong consistency.
Design a Payment System (Stripe-style)
Move money correctly. Double-entry ledgers, idempotency keys, the authorize/capture/settle lifecycle, reconciliation, and why money never gets eventual consistency.
Design a Distributed Counter (view / like counts)
Count likes and views at millions of increments per second without a single hot row melting. Sharded counters, write batching, and approximate vs exact counts.
Design a Calendar System (Google Calendar)
Store events, share calendars, find free slots, and fire reminders — across time zones and recurring rules. The RRULE expansion and free/busy problem.
Design a Hotel / Airbnb Booking System
Search available listings and book date ranges without double-booking. Availability as a range problem, reservation holds, and the search vs transaction split.
Quorums, Read-Repair & Anti-Entropy (Dynamo-style)
How leaderless databases like Dynamo and Cassandra stay available and converge. Quorum R+W>N, read-repair, hinted handoff, Merkle anti-entropy, and conflict resolution.
Design a Stock Exchange (matching engine)
Match buy and sell orders deterministically with microsecond latency and perfect fairness. The single-threaded matching engine, the order book, and event sourcing for recovery.
Event Sourcing & CQRS
Store every change as an immutable event and rebuild state by replay. Event sourcing, CQRS read models, snapshots, and the trade-offs nobody warns you about.
Change Data Capture (CDC) & the Outbox Pattern
Turn your database write log into a reliable event stream. Log-based CDC, the dual-write problem, and the transactional outbox.
The Saga Pattern & Distributed Transactions
How do you keep data consistent across services with no shared database? Sagas, compensating transactions, orchestration vs choreography, and why 2PC fails at scale.
Database Replication
Single-leader, multi-leader, and leaderless replication. Sync vs async, replication lag, conflict resolution, and how each model trades availability for consistency.
Design a Distributed Key-Value Store (Dynamo)
Build your own DynamoDB / Cassandra. Sharding, replication, quorum reads/writes, vector clocks, conflict resolution.
CAP Theorem Deep Dive
The CAP theorem, debunked myths, PACELC, and the actual trade-offs every distributed database makes.
CAP, Consistency, and Replication
CAP and PACELC, consistency models from linearizable to eventual, replication strategies, quorums, partitioning, consensus (Raft, Paxos), CRDTs, and 2PC.