Full answer
Definitions
Scalability is the ability of a system to handle more load (users, requests, data) by adding resources, without a redesign.
- Vertical scaling (scale up): replace or upgrade one server. A database moves from 8 cores and 32 GB RAM to 64 cores and 512 GB RAM.
- Horizontal scaling (scale out): add more servers of the same kind and split traffic or data across them. A web tier grows from 3 to 30 identical app servers behind a load balancer.
Think of a school canteen. Vertical scaling is hiring one faster cook. Horizontal scaling is opening more counters. The faster cook has a limit, and if that cook is sick, nobody eats. More counters need a queue system to send students to a free counter.
How each works
Vertical scaling needs no code change. The same process simply has more resources. The limits are physical (the biggest machine you can buy or rent), cost (large machines cost more per unit of capacity), and availability (one machine is one failure point, and upgrades often need a restart).
Horizontal scaling needs three things:
- A load balancer to spread requests.
- Stateless app servers, so any server can serve any request. Session data moves to a shared store such as Redis or into a signed token.
- For data, replication (copies for reads) and sharding (splitting data across machines for writes and size).
When to use which
- Start vertical for a relational database when the data fits and write load is moderate. It keeps transactions and joins simple.
- Go horizontal for stateless web and API tiers early, because it is cheap and also gives redundancy.
- Move a database to horizontal (read replicas, then sharding) when one machine cannot hold the data, the write rate, or when downtime from one box is not acceptable.
Example
An exam-results site gets 50 times its normal traffic on result day. Adding app servers behind a load balancer (horizontal) handles the spike, and a read replica plus a cache in front of the results table absorbs the read storm. Making the single database server bigger would help only until the next result day doubles the load again.
By level
Fresher: Define both terms with a simple example and name the main limit of each. Explain that horizontal scaling needs a load balancer and servers that do not keep user state in memory. A short canteen or exam-day example is enough at this level.
Mid: Explain how to make a service stateless (external session store, tokens) and how databases scale differently from app servers: read replicas for reads, sharding for writes. Discuss cost per unit of capacity and when a single large database is the right call. Expect at least one number, such as how many app servers a traffic spike needs.
Senior: Discuss where horizontal scaling stops being linear: coordination, cross-shard queries, hot partitions and fan-out. Talk about failure domains, autoscaling signals and lag, and the operational cost of many small nodes versus a few large ones. A strong senior answer also says when not to scale out yet.
Key points
- Vertical = bigger machine; horizontal = more machines
- Vertical is simple but has a ceiling and a single point of failure
- Horizontal needs a load balancer and stateless services
- Databases usually scale reads with replicas and writes with sharding
- Most real systems combine both
Common mistakes
- Saying horizontal scaling is always better; it adds coordination cost and complexity
- Forgetting that sticky in-memory sessions block horizontal scaling
- Claiming vertical scaling needs no downtime; many upgrades require a restart or failover
- Treating a database the same as a stateless web server
Follow-ups
- How do you make a stateful service horizontally scalable?
- Why are writes harder to scale out than reads?
- What breaks first when you add the 100th app server?
Tips
- Use the words scale up and scale out, then give one limit of each
- Mention statelessness as the precondition for horizontal scaling
- Separate the app tier from the data tier in your answer
Evaluation rubric
- Defines both terms correctly
- Names at least one limit of vertical scaling (ceiling, cost, single point of failure)
- Explains what horizontal scaling requires (load balancer, stateless servers, data partitioning)
- Gives a sensible example of when to pick each