Scaling writes: sharding, batching and write buffers
On election night every ballot has to be counted once, and photocopies help nobody, since a second table counting copies adds no new votes. So the count is split by district, each with its own table, and staff carry ballots there in sealed bundles, never one at a time. Voters drop their ballot in the box and go home long before anyone counts it.
Voters are users, ballots are writes and a counting table is a database leader, so districts are shards and the district on a ballot is the shard key. The staff are workers, a sealed bundle is a batch, and the ballot box is a write buffer, a durable log such as Kafka that accepts writes first. Read replicas copy every write and add no room for more, and interviewers listen for the move that does: make each write cheaper, let a durable buffer absorb the bursts, and shard once the sustained rate or the data outgrows one leader.
The photo app at peak: 25,000 likes a second. The like service appends each one to Kafka, which keeps three copies, and answers the phone.
1 / 3In the diagram, the like service appends each like to Kafka and answers; workers then send each shard its users' likes in batched inserts.