Free sample lesson ยท System Design Foundations

Server-Database Separation

What happens when your startup's all-in-one server can't keep up with success?

Lesson 1 of the Wondering course System Design Foundations

Everything On One Box

Your first deployment is usually one server doing all the work.

The web app, the database, and the cache all share the same CPU, memory, and disk. One machine handles DNS resolution, HTTP requests, and every data operation.

A single server box containing web app, database, and cache

Notice that the web app, database, and cache sit inside one machine boundary, so they compete for the same CPU, memory, and disk.

This is simple to deploy, cheap to run, and easy to debug.

It is also the setup that breaks first when traffic grows.

How A Request Flows

Follow one user request through the single server setup.

The browser resolves the domain through DNS, gets an IP address, then sends an HTTP request to that address.

The web app on that server handles the request and reads or writes data locally.

One request on a single server
  • DNS lookup: The browser resolves the domain name into an IP address.
  • HTTP request: The browser sends an HTTP request to that IP address.
  • App handles: The web app on the server processes the incoming request.
  • Data operation: The app reads or writes data on the same machine.
  • Response back: The response travels back to the browser from that one server.

The response travels back. Every stage happens on one machine.

Why One Machine Runs Out

A single server is limited by single-machine capacity.

That means one pool of CPU, one pool of memory, one disk. Your web tier and your data tier fight over the same resources.

A heavy query can starve request handling. A traffic spike can starve the database.

Why does success break the simple setup?

Success is what exposes this limit.

Two Tiers Hiding Inside One

Inside that single server, two very different workloads are hiding.

The web tier is compute work: parsing requests, running application logic, building responses.

The data tier is storage work: reading, writing, and persisting data durably.

Two workloads on one machine
  • Web tier
  • Data tier

They grow at different rates and need different hardware. Yet on one box they are forced to share.

The First Scaling Move

The first major scaling step is moving the database onto its own server.

Nothing about your application logic has to change fundamentally. The web server now reaches the database over the network instead of locally.

What changes is the boundary.

Web server and database server split across two machines

Notice the database has moved outside the web server's box, so the two tiers now talk across a network link instead of sharing one machine.

Compute and storage stop competing for the same machine.

Independent Scaling

Separation buys you one thing above all: independent scaling.

If request volume climbs, add web servers without touching the database. If your dataset grows or queries slow down, give the database more memory and faster disks.

Each tier gets the hardware profile it actually needs.

Single server versus separated database
  • Single server
  • Separated database

On one box, every upgrade meant paying for both.

.

What The Split Costs

Separation is not free.

Data access now crosses the network, so every query carries latency it did not have before. You have a second machine to configure, secure, and monitor.

A network failure between the tiers is a new way for the system to break.

Where each setup sits
  • Single server
  • Separated tiers

The trade is worth it because the ceiling moves. Complexity is the price of headroom.

Knowing When To Split

Do not separate on day one out of habit. Separate when the evidence says to.

Watch for the database and the web app competing: CPU pinned during queries, memory pressure, disk contention.

Ask one question. Is the bottleneck compute or storage?

Should you separate the database?
  • Single server running: Web app, database, and cache share one machine.
  • Resource contention?: CPU pinned during queries, memory pressure, or disk contention.
  • Keep it simple: Stay on one box while it is cheap and easy to debug.
  • Compute or storage?: Identify which tier is the real bottleneck.
  • Move database out: Give the database its own server.
  • Scale each tier
  • Keep watching
  • Either tier

If you cannot answer it on one box, that is your signal to split.

Key Takeaways

One server is a fine starting point and a poor ending point.

The web app, database, and cache all sharing one machine is simple but limited by single-machine capacity.

Separating the database is the first major scaling step. It lets you scale compute and storage independently.

The first scaling decision
  • Single server: Web app, database, and cache all run on one machine.
  • Machine capacity: One server is limited by single-machine capacity.
  • Web tier: The compute side that handles HTTP requests.
  • Data tier: The storage side that reads and writes data.
  • Network hop: Data access now crosses the network and carries latency.

Everything after this, replication and caching layers, builds on that boundary.

Check yourself

Moving the database to its own server allows the web tier and data tier to scale independently.

  • True
  • False

Answer: True

Correct. Separation gives each tier its own machine, so web capacity and database capacity can be adjusted separately. Keeping both on one server forces upgrades to support both workloads together.

Word pool: web tier; data tier. Parsing requests and building responses belong to the _____, while reading and durably storing data belong to the _____.

Answer: Word pool: web tier; data tier. Parsing requests and building responses belong to the web tier, while reading and durably storing data belong to the data tier.

The web tier performs compute-oriented request and application work. The data tier performs storage-oriented reading, writing, and durable persistence. These workloads may share one machine initially but have different resource needs.

A web application and its database share one server. Queries are causing CPU and memory pressure, while request traffic is also increasing. What is the first major scaling move described here?

  • Move the database to its own server
  • Add a cache while keeping everything on one server
  • Replace the web application with a different framework
  • Combine database queries with request parsing

Answer: Move the database to its own server

Moving the database to its own server separates compute work from storage work. The application can then reach the database over the network, allowing each tier to receive hardware suited to its workload.

Keep going

This is lesson 1 of 52 in System Design Foundations. Next up:

  1. Scaling with Caching Layers
  2. Load Balancers & Stateless
  3. Caching & CDNs
  4. Power of Two
  5. Latency & Storage

Start this course free

Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.