Delivery in10 minutes
Home · Indiranagar, BLR-07
8 PM sale
Starts at 8 PM
Half price on one favourite
All products
- Butter₹56
- Bread₹52
- Eggs₹100
- Maggi₹14
- Mangoes₹98
- Milk₹32
- Rice₹89
- Sugar₹48
- Tomatoes₹30
Delivery in10 minutes
Home · Indiranagar, BLR-07
8 PM sale
Starts at 8 PM
Half price on one favourite
All products
Delivery in10 minutes
Home · Indiranagar, BLR-07
8 PM sale
Starts at 8 PM
Half price on one favourite
All products
Zepto’s products table at its 8 PM sale, split across three machines or copied to three: a flash deal, a rush of orders, then a crash. Illustrative numbers.
Replicate to share reads and to survive a crash. Shard when the writes or the data outgrow one machine. Big systems do both: they shard the data, and replicate every shard.
| Difference | Sharding | Replication |
|---|---|---|
| Each machine holds | A part of the data | All of it |
| Reads | Split by key: a hot item overloads one shard | Any copy answers |
| Writes | Split across the shards | All go to the primary |
| A machine dies | Its part is gone until it’s back | A replica takes over |
| Use it for | Data or writes too big for one machine | Heavy reads, staying up |
Tonight is Zepto’s 8 PM sale, and one table holds every product, its price, and how many are left. One machine can’t carry the night alone.
On the left, sharding: the table is split by name across three machines, each holding a third. On the right, replication: the whole table is copied to three machines, one primary and two replicas. Let’s follow the sale through three moments.
First, 8 PM: mangoes at half price, and thousands of shoppers open the same page.
Mangoes live only on the second shard, so every one of those reads lands there.
It runs hot, while the other two sit idle.
With replication, every machine holds mangoes, so any of them can answer, and the same crowd is shared three ways.
A replica may be a moment behind the primary, which is fine for a product page.
Next, the orders pour in, and each one lowers a stock count: thirty thousand writes a second.
Each write goes only to the shard that owns that product, so the load splits three ways, about ten thousand each.
Say one machine handles fifteen thousand: every shard keeps up.
With replication, every write must go to the primary first, and is then copied to both replicas.
Copies add readers, never writers: the primary takes all thirty thousand, and falls behind.
Finally, at the peak, the second shard’s machine crashes.
Everything from I to P goes with it: Maggi, mangoes and milk can’t be shown or sold until it’s back.
When the primary crashes here, a replica is promoted to primary within seconds.
Every product is still on every machine, so shoppers barely notice.
So which should you pick? They solve different problems. Replicate to share reads and to survive a crash. Shard when the writes or the data outgrow one machine. Big systems do both: they shard the data, and replicate every shard.