Replication vs sharding: which statement is correct?
Options
- Both split the data across nodes, using the same technique
- Replication copies data to nodes; sharding splits data across them (Correct option)
- Sharding is only used for caching the results of queries
- Replication improves write throughput in a linear way
Answer
Replication copies the same data to several nodes (read scaling, availability); sharding partitions data across nodes (write and storage scaling)
Why
Replication: several servers hold a COPY of the same data. If one dies, another takes over, and reads can be spread across copies.
Sharding: data is SPLIT; each server holds a different part (e.g. users A-M on one, N-Z on another). This scales writes and storage.
Sharding needs a good shard key and makes queries across shards harder.
Remember
Replication = copies. Sharding = pieces.