Replication
Replication maintains multiple copies of the same logical database. Typically there is a single primary (master) that accepts writes and one or more read replicas that asynchronously or synchronously copy data from the primary. Key benefits and considerations:- Scales read throughput by distributing read-only queries to replicas.
- Improves availability and failover: replicas can be promoted to primary if the primary fails.
- Does not increase single-node write throughput in a primary-replica setup — all writes still go to the primary.
- Multi-primary (multi-master) replication exists but introduces conflict resolution, ordering, and consistency trade-offs.
- Replication modes matter:
- Synchronous replication: stronger durability, higher write latency.
- Asynchronous replication: lower write latency, potential for data loss on failover.
- Read-heavy workloads (e.g., content-serving sites where reads greatly outnumber writes).
- High availability and fast failover requirements.

Sharding
Sharding (horizontal partitioning) splits a large dataset across multiple independent databases (shards). Each shard holds a distinct subset of the data so no single database contains the entire dataset. Why shard:- Increases write throughput and storage capacity because writes for different shards can be handled in parallel by separate machines.
- Allows datasets to exceed the storage limits of a single server.
- Requires a sharding key and routing logic so queries are sent to the correct shard.
- Cross-shard joins, distributed transactions, and global consistency become harder.
- Rebalancing shards (splitting or moving data) is operationally complex.
- Common strategies: range-based sharding, hash-based or consistent hashing, and directory-based routing.
Sharding adds significant operational and application complexity. Avoid sharding until write throughput or dataset size makes it unavoidable — premature sharding increases maintenance cost and failure modes.
Which to choose?
When someone reports a database is “under load”, first determine whether the bottleneck is reads, writes, or storage size:- Read-heavy (many more reads than writes): try caching (CDN, in-memory caches) and read replicas first.
- Write-heavy or dataset-too-large: sharding is usually the right solution because it increases concurrent write capacity and total storage.
- Availability: every shard should itself be replicated — in production you typically combine sharding and replication: each shard is replicated for failover and replicas can serve reads for that shard.
- Is the system read-heavy? Start with caching + replication.
- Is the single primary saturated for writes or data exceeds single-node capacity? Consider sharding.
- Can you accept increased operational complexity (cross-shard transactions, rebalancing)? If not, redesign or scale vertically first.
Comparison at a glance

Quick summary
- Replication: easier to implement, improves read throughput and availability; a single primary typically limits write throughput.
- Sharding: increases write throughput and overall storage capacity at the cost of higher application and operational complexity.
- Real-world approach: prefer caching and replication first. Adopt sharding when table size or write throughput forces it, and always replicate each shard for availability.
Prefer caching and replication before sharding. Only shard when write throughput, dataset size, or latency requirements make it unavoidable, and ensure each shard is replicated for availability and failover.
- Database Sharding: Concepts and Best Practices
- Read Replicas and High Availability patterns
- For deeper reading on consistency and replication modes, search for “synchronous vs asynchronous replication” and “multi-master replication tradeoffs.”