Scaling

Bigger or more machines · Part of Networking and infrastructure

Key idea

Practice

7 questions · about 4 min

Explained step by step

Scalability

Scalability measures how well a system responds when demand changes, by adding or removing resources. If an app goes from 1,000 to 100,000 users, a scalable system copes by adding machines or power, without rewriting everything. It's like a restaurant: if more customers come, you add tables and waiters. It works the other way too: at night, with 10 times less traffic, you remove resources and pay less.

Scaling horizontally

There are 2 ways to scale. Vertical (scale up) makes the machine you have more powerful: more CPU, more RAM, more disk. Horizontal (scale out) adds more machines to the pool and splits the load among them. It's like moving house: vertical is buying a bigger truck, horizontal is using 3 regular trucks. Going from 16 to 64 GB of RAM is vertical; going from 2 to 8 servers is horizontal.

Scaling horizontally has costs too. It adds complexity: more machines to configure, a load balancer, more things to watch. And it increases load on the services behind it (downstream), like the database or the cache: each new server opens its own connections. It's like opening 10 branches that buy from the same supplier: the supplier gets 10 times more orders. If each server opens 50 connections, 10 servers make 500.

Scaling vertically

Scaling vertically has a ceiling: at some point there's no bigger machine for sale. Also, growing it often means shutting it down, and if that single machine goes down, everything goes down: it's a single point of failure. It's like having only 1 cook: however fast they are, if they get sick, the restaurant closes. With 5 regular machines, if 1 fails, 80% keeps working.

Scaling vertically has advantages: it's simple to do, easier to manage, and data stays consistent, because it lives on 1 single machine with no copies to drift apart. It's like a shop with 1 single till: no need to add up several tills at the end of the day. That's why many systems start with 1 server and grow it, until they hit the ceiling or need to never go down.

Redundancy

Scaling horizontally adds redundancy: if one machine fails, the others carry on, so it tolerates failures better. It's flexible, because you can add or remove machines with demand, and easier to upgrade: you update 1 machine at a time while the others serve. It's like a team of 10 couriers: if 1 is missing, the other 9 still deliver. That's why big systems almost always scale horizontally.

Consistency

With several machines, data can be inconsistent: one has the new version and another still has the old one. If you change your profile photo and the next request lands on a server that hasn't caught up, you see the old photo. It's like 2 cashiers with different price lists: depending on which you go to, you pay a different price. With 1 single machine this doesn't happen, because there's 1 single copy of the data.

Terms in this lesson

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.

Key idea

Bigger or more machines