Database Capacity

The connection-pool ceiling, read replicas, write throughput, and sharding strategies.

Overview

Why databases need their own capacity plan

Databases are usually the first thing to break under load and the hardest thing to scale. That is why database capacity planning is its own subspecialty.

A typical setup has three tiers. Each app instance keeps its own connection pool. The instances do not connect to the database directly; they go through a connection pooler such as PgBouncer, ProxySQL or RDS Proxy. The pooler sends every write to the primary, which takes all writes and copies them to read replicas by asynchronous replication. Reads can go to those replicas instead of the primary. Each tier has its own ceiling, and this chapter takes them in turn: connections first, then reads, then writes.

> [!IMPORTANT] Most teams scale apps horizontally with ease but hit database limits painfully. Plan database capacity first and let app capacity follow.

Key concepts

  • Connection pool ceiling
  • Read replicas
  • Sharding
  • CQRS
  • Distributed SQL
  • Hot shard

Interview questions

  • My Postgres is hitting connection limits. What do I do?
  • When do you shard a database vs scale up?
  • How do you plan for database failover during peak load?

Sign up free to read the full topic

More SRE topics

Start free on Cariara · Coding problems · System design studio