Loading…
Loading…
Charting your lesson…
Opening your lesson…
Scalability & Load Balancing
Lesson 1 of 6
How systems grow with load — vertical vs horizontal scaling — and how load balancers spread traffic across servers.
6 steps•about 11 min•8 flashcards
Step 1/ 61 min
In a placement system-design round, the first thing an interviewer probes is: "your service is getting 10x traffic — what breaks, and how do you grow?" Getting scalability and load balancing right is the backbone of almost every answer.
Step 2/ 62 min
Scalability is a system's ability to handle growing load — more users, requests, or data — without a collapse in performance. You grow in one of two directions. Vertical scaling (scale up) means putting a bigger machine underneath: more CPU, RAM, faster disk. Horizontal scaling (scale out) means adding more machines and splitting the work between them. A load balancer is the traffic cop that sits in front of a pool of servers and distributes incoming requests so no single server is overwhelmed.
Vertical scaling is the simplest: no code changes, just a bigger box. But it has a hard ceiling (the biggest machine money can buy) and a single point of failure. Horizontal scaling has no real ceiling and gives you redundancy, but your app must become stateless — any server should be able to handle any request. That usually means moving session state out to a shared store like Redis.
A load balancer picks which server gets each request:
Load balancers also run health checks, pulling a dead server out of rotation automatically.
Load balancing happens at Layer 4 (transport — routing by IP/port, very fast) or Layer 7 (application — routing by URL, headers, cookies, enabling smart rules). Scaling the web tier is easy; the database usually becomes the bottleneck, which is why read replicas, caching, and sharding follow. The load balancer itself must not be a single point of failure — you run it in an active-passive or active-active pair.
Step 3/ 61 min
An app on one server maxes out at 2,000 requests/sec. Traffic climbs to 8,000 req/sec. Vertical scaling can't get you 4x affordably. Instead you put four stateless app servers behind a load balancer using least-connections, move sessions to Redis, and add health checks. Now the tier handles ~8,000 req/sec with a spare server tolerating one failure.
Step 4/ 61 min
Reach for horizontal scaling + a load balancer whenever you need high availability or growth beyond one machine — essentially every web-scale service. Use vertical scaling early, for quick wins, or for hard-to-distribute components like a primary database.
Step 5/ 61 min
Remember "UP is a bigger box, OUT is more boxes." Up hits a ceiling and a single point of failure; out scales forever but demands statelessness.
Don't assume you can scale horizontally without making the app stateless. If sessions live in server memory, adding servers breaks logins unless you use sticky sessions (which hurt balance) or externalize state.
Step 6/ 6· Worked examples1 min
Problem
A web app runs on one server handling ~1,200 requests/second. Peak traffic is projected to reach 5,000 req/s. How would you scale it, roughly how many servers are needed, and how are requests distributed?
Try it on paper first.
Recall
Keep this
Quick revision of how systems grow under load and how traffic is spread.
You've read 0 of 6 steps
Now lock it in — questions straight after reading are what make it stick.