Scalability
Масштабируемость
Scalability describes how well a system can handle more work when given more resources, without response times or error rates getting worse than users can tolerate.
Also known as: горизонтальное масштабирование, вертикальное масштабирование
What scalability measures
A service can be fast today and still be hard to scale. A leaderboard API might respond in 30 milliseconds during a quiet afternoon, but adding servers may barely help on game night if every request has to read from the same overloaded database. Performance tells you how the system behaves at a given workload and resource level. Scalability tells you how much more work it can handle as you add resources, while still meeting targets for response time and errors.
Two ways to add capacity
- Scale up (vertical scaling): give one instance more resources, such as more memory or CPU cores. Moving a database to a larger machine is often simpler than splitting its data across machines, but there is a limit to how big that machine can get.
- Scale out (horizontal scaling): add instances and divide the work among them. A load balancer can spread requests across API instances. If one instance keeps a user's session only in local memory, another instance won't have it. Storing session data in a shared store can solve that problem, but the store now needs enough capacity for the combined load.
These approaches can coexist. You might scale out the API tier while scaling up its database. Autoscaling is a separate idea: it automates resource changes in response to signals such as CPU usage or queue depth. It won't fix a shared bottleneck on its own.
Example: adding workers to an image pipeline
An image service takes resize jobs from a queue. With one worker, it processes 100 images per minute without the queue growing. With four workers and the same mix of image sizes, it handles only 230 per minute. If metrics show that the workers spend most of their time waiting to download originals and that shared storage is at its bandwidth limit, more workers won't help much. The team could test a storage setup with more bandwidth, then measure both completed jobs per minute and the time from enqueueing to completion. That second metric matters: workers can finish individual jobs quickly while users still wait behind a growing backlog.
Common mix-ups
Scalability is not the same as high availability. A larger database may handle more traffic but still go offline if its only node fails. Nor does scaling out imply linear gains: coordination and shared dependencies can make four instances deliver less than four times the throughput. Adding a queue can absorb a short burst, but it doesn't increase the rate at which workers finish jobs.
How it comes up in interviews
In system design interviews, you might be asked what you'd change if traffic grew tenfold. Clarify peak traffic, the read/write mix, and acceptable latency before choosing a design. Identify what will saturate first and say how you'd check: for instance, use a load test to measure sustainable throughput at a fixed latency target. Explain why your change addresses that constraint before proposing the next one.