Enterprise engineering

Read replicas, partitioning or sharding?

Pick by the bottleneck:

  • Vertical scaling — working set or CPU under-provisioned; has a single-node ceiling and failover cost
  • Read replica — reads saturate the primary and slightly stale reads are fine; watch replica lag and read-your-writes routing
  • Partitioning — very large time-series tables and fast retention deletion; adds query-plan and key/index complexity
  • Sharding — one node truly can't cope after optimisation; brings cross-shard joins/transactions and resharding pain
  • Horizontal stateless app tier — more app instances, but the database, cache and shared state can still be the bottleneck

Order of attack: measure with EXPLAIN → add indexes → fix N+1 queries → cache hot reads → tune the connection pool → scale vertically → replicas → partitioning → sharding last.

All guides