Question presented to candidate: "Our API is running hot on a single server and traffic keeps growing. You could move it to a bigger machine, or run several copies behind a load balancer. Walk me through the difference between vertical and horizontal scaling, when you would pick each, and what the second option forces you to change."
What a strong answer should cover:
- Clear definitions: vertical scaling (scale up) adds CPU, RAM or faster disks to one machine; horizontal scaling (scale out) adds more machines and spreads load across them
- Vertical needs no code change but has a hard hardware ceiling, usually needs a restart to resize, and stays a single point of failure
- Horizontal gives redundancy and near-elastic capacity, but only if the service is stateless (or the data is partitioned) and a load balancer sits in front
- Scaling out is not free: shared bottlenecks (a lock, one primary database) and coordination cost make throughput flatten or even fall (Amdahl's law, Universal Scalability Law)
- Availability arithmetic: one node at 99.5% vs N+1 nodes where one may fail; and the usual real path β scale the database up first, scale the stateless tier out, then add replicas and shards
Clarifying questions expected:
- Which tier is the bottleneck: the stateless web/API tier or the stateful database?
- Is the problem throughput, latency, or availability (do we also need to survive a machine failure)?
Code / implementation expected: Optional β the throughput and availability arithmetic (as in the example) is more useful than code; no implementation is required.