Scalability

A system's ability to keep working well as usage grows: more users, data, and requests.

What is it?

A system that works with a hundred users might fail with a million. Scalability means designing it to keep up as demand grows, ideally by adding resources rather than redesigning.

There are two main strategies:

  • Vertical scaling: make one server more powerful (more CPU, more memory).
  • Horizontal scaling: add more servers and spread the work across them.

Most large systems end up relying on horizontal scaling, because one machine can only get so powerful.

Explain like I'm 10

Vertical scaling is like hiring one super-employee who works ever faster. Horizontal scaling is hiring more employees and splitting the work. Eventually no single employee, however fast, can outpace a team.

Examples

The idea, not literal code

// Vertical scaling: same one server, upgraded hardware
// 4 CPU cores, 8GB RAM → 32 CPU cores, 256GB RAM

// Horizontal scaling: same modest servers, more of them
// 1 server → 10 servers, behind a load balancer

How it works

Scalable systems keep individual servers from holding state only they know about. Then any server can handle any request, and you can add more freely.

This relies on other pieces working together: load balancers to spread traffic, caches to avoid repeated work, and databases built for growing data.

Why does it exist?

Growth is often the whole point of a product. A system that can't scale becomes slow or falls over exactly when it finally gets popular. Designing for scale early avoids painful, risky rewrites later.

When to use it

Plan for scalability once real growth is likely soon: when you expect the system to handle meaningfully more users, data, or traffic than it does today.

When not to use it

Don't over-invest in horizontal scaling, statelessness, and distributed architecture for a prototype or an app with a small, stable user base. That complexity costs real effort, and early scaling work often bogs projects down before they ship.

Common mistakes

  • Only scaling vertically until you hit the ceiling of the biggest machine available.

  • Keeping important state on one server (like data in memory), which breaks horizontal scaling because other servers can't see it.

  • Over-engineering for scale the product doesn't need yet, adding complexity too early.

Practice exercises

  1. Easy:

    Explain in your own words the difference between vertical and horizontal scaling.

  2. Medium:

    Describe a design decision that would make horizontal scaling harder, and how you'd avoid it.

  3. Hard:

    Sketch (in words) how load balancing, caching, and a scalable database work together to let a system handle 100x more users.

Interview questions

What's the difference between vertical and horizontal scaling?

Vertical scaling adds power to one machine. Horizontal scaling adds machines and spreads the work across them.

Why do most large systems eventually favor horizontal scaling?

A single machine has a physical and cost ceiling, while adding machines can, in principle, go on indefinitely.

Why is storing state only on one server a scalability problem?

Other servers can't see it, so requests must always go back to that server, which breaks the flexibility horizontal scaling depends on.