Stage 4 · Provision
Database Scaling Strategies
Vertical Scaling & Read Replicas
When to scale up vs out, synchronous vs async replication, and read replica strategies.
Vertical Scaling
Vertical scaling (scale up) means adding more CPU, RAM, or disk to a single server. It is the simplest way to handle increased load — no code changes, no distributed systems complexity. For many workloads, vertical scaling is the right first step.
| Dimension | Vertical Scale Up | Horizontal Scale Out |
|---|---|---|
| Complexity | Low | High |
| Consistency | Strong (single node) | Requires replication logic |
| Cost | Exponential at high end | Linear |
| Limit | Hardware ceiling | Theoretically unlimited |
| Downtime | Required for resize | Can be zero-downtime |
Scaling Limits
Vertical scaling hits physical limits. The largest cloud instances offer 128 vCPUs, 4TB RAM, and fast NVMe storage. Beyond that, you must scale horizontally. Most databases hit vertical scaling limits at 10-50K QPS depending on query complexity.
Many teams prematurely adopt sharding when a larger instance would solve their problem. A singlePostgreSQL instance on a 64-vCPU machine with 256GB RAM can handle tens of thousands of QPS. Start with vertical scaling.
Read Replicas
Read replicas are copies of the primary database that handle read traffic. This offloads the primary and improves read scalability. The primary handles writes, replicas handle reads. This is the most common first step in database scaling.
Application
│
├── Writes ──► Primary (us-east-1)
│ │
│ │── async replication ──► Replica 1 (us-east-1)
│ │── async replication ──► Replica 2 (us-west-2)
│ └── async replication ──► Replica 3 (eu-west-1)
│
└── Reads ──► Read Router ──► Replica (nearest region)The application routes reads to replicas and writes to the primary. Read routing can be done at the application level, connection pooler (PgBouncer), or proxy (ProxySQL).
Synchronous vs Asynchronous Replication
| Type | Consistency | Latency | Durability |
|---|---|---|---|
| Synchronous | Strong (read-after-write) | High (waits for replica) | High (ack after replica) |
| Asynchronous | Eventual (may read stale) | Low (immediate ack) | Lower (replica lag) |
| Semi-synchronous | Between | Moderate | Moderate |
Replica Topologies
- Single primary, multiple replicas — Simple, most common. One writer, many readers.
- Cascading replicas — Replica replicates to another replica. Reduces primary load but increases lag.
- Multi-primary — Multiple writable nodes. Complex conflict resolution required.
- Ring replication — Each node replicates to the next. Used in Cassandra.
When to Scale Out
- Write throughput exceeds single-primary capacity.
- Read latency increases due to primary contention.
- Storage exceeds single-disk capacity.
- You need geographic distribution for latency or compliance.
Read replicas scale reads cheaply. Sharding scales everything but introduces massive complexity. Exhaust read replicas and caching before considering sharding.
Mark this lesson complete to store local progress and unlock a cleaner resume path the next time you visit.