Skip to content
BENIBIX Learn

Replication vs Sharding

Replication puts a full copy of the data on each server. Sharding splits the rows, so each server holds just a part.

Development🗃️ Databases

Database Replication

Live copies of a database kept on other servers. If one fails, the rest go on.

Database replication keeps copies of a database on more than one server. One server, the primary, takes the writes. It sends each change to the others, called replicas, which apply it too. If the primary fails, a replica can take over. Replicas can also share the work of reading, which spreads the load.

Example
Emma's shop runs one main server and two copies in other places. When the main disk dies, a copy takes over in under a minute.
Why it matters
One server is one point of failure. Replication keeps the data safe and the app running.
Full entry
Development🗃️ Databases

Database Sharding

The rows of a big database, split across many servers. Each holds a part.

Sharding splits the rows of one big database across several servers. Each server, called a shard, holds only part of the data. A shard key, like the user id, decides which shard each row lives on. This lets a database grow past what one server can hold or handle. It adds a lot of work, so most teams shard only when nothing else is enough.

Example
A chat app with 500 million users puts users 1 to 100 million on shard one, and so on. Each server only carries a fifth of the load.
Why it matters
There is a limit to how big one server can get. Sharding is how the largest apps go past it.
Full entry

In one line

Database Replication
Live copies of a database kept on other servers. If one fails, the rest go on.
Database Sharding
The rows of a big database, split across many servers. Each holds a part.