Skip to content

Lesson 3 of 3

Scaling beyond one server

1 min

When one server is no longer enough, first scale up (more CPU and RAM). It's simple and often enough. When it isn't, scale out.

Step 1: separate the database

Move the database to its own server. The web server and database stop competing for memory, and each can be sized for its job.

Step 2: make web servers stateless

Before adding a second web server, remove anything stored on its local disk:

  • Sessions → Redis or the database
  • Uploads → object storage or a shared volume
  • Cron jobs → run on one server only

Step 3: add a load balancer

A load balancer spreads requests across web servers and health-checks them, removing a failed server automatically.

upstream app {
    server 10.0.0.11;
    server 10.0.0.12;
}

Step 4: read replicas

If the database becomes the bottleneck, add read replicas for reports and search, and keep writes on the primary.

Each step adds moving parts. Add monitoring and a tested restore plan before adding servers; more servers means more ways to fail.