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.
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.
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.
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.