Section 9: One Seller, One Shard - Data Storage, Partitioning & Scalability
Executive Summary: Sections 5 through 8 created a lot of rows: journal transactions, postings, payment attempts, idempotency records, raw webhooks and outbox events. This section decides where each one lives. Each kind of truth gets its own store. The ledger is sharded by seller_id into 64 logical shards on 8 Postgres clusters, so every journal transaction commits on one shard. The real bottleneck is a handful of hot balance rows, not raw throughput, and we split those rather than adding hardware. Ten years of history fits in 105 TB of hot disk plus a 17.5 TB compressed archive.
The interviewer points at the 120M postings a day from Section 2. "Where does all of this live, and what breaks first?" You name the trap first: 3,500 journal transactions a second is modest for a database. What breaks first is contention on a few rows.
One Store Per Kind of Truth
| Data | Store | Consistency | Volume |
|---|---|---|---|
| Journal, postings, balances | Sharded Postgres, keyed by seller_id (D4) |
Strong, single-shard ACID | 120M postings/day |
| Ledger idempotency keys | Same shard, same transaction (D10) | Strong | One per journal txn |
| Payment intents, attempts, captures | Postgres, sharded by payment_id (a cart spans sellers) |
Strong | 25 GB/day |
| Raw PSP webhooks | Object storage + index on unique event_id |
Write-once | 120 GB/day, 90 days hot |
| Outbox events | Kafka, fed by the in-shard outbox (D8) | Ordered per seller (partition key) | ~60M/day |
| Dashboards, payment status | Read replicas + document-store projection | Eventual, ≤ 5 s | ~10,000 reads/s peak |
| Analytics | Warehouse | Eventual | Batch and stream |
| 10-year record | WORM object storage, columnar | Immutable | 17.5 TB compressed |
For ord_7Q2, Maya's payment intent and $120 authorization live in the payments database. The lamp capture posts on Lantern & Loom's shard k, the tea capture on Copperleaf Tea's shard k'. Two shards for one order is fine: each journal transaction belongs to one seller.
Sign in to continue reading
The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.
Sign in to read the full lesson