How would you scale a relational database as traffic grows?
Scaling relational databases follows a progression, because a single node eventually hits CPU, memory or I/O limits.
- Optimise first: fix queries, add indexes, tune the buffer pool and connection pooling, and archive old data.
- Read scaling: add replicas and route reads to them, accepting replication lag. Use a cache such as Redis for hot data.
- Vertical scaling: more RAM and faster disks, such as NVMe, often beat complex sharding and buy time.
- Partition large tables by range or hash to keep working sets manageable.
- Shard: split data across nodes by a shard key so writes scale. This makes cross-shard joins, transactions and unique constraints hard.
app -> primary (writes)
| replication
v
replicas (reads) + cache
Choose the shard key for even distribution and locality, and plan resharding and rebalancing. Some workloads are better served by a NoSQL or NewSQL store, or by CQRS with separate read and write models.