Sub topic 10
Scalability requirements
This chapter assumes you can read short Python snippets and know the basics of client-server systems, databases and caching. It also assumes you have read the chapter on performance requirements, so latency, throughput and percentiles should already be familiar.
What scalability means as a requirement
Scalability is the ability of a system to keep meeting its targets as load grows. "The system must scale" is not a requirement, because it has no number and no test. A usable scalability requirement names three things:
- The load dimension that grows, such as requests per second, stored items or concurrent users.
- The growth target, such as 10x in 12 months.
- The quality that must hold while it grows, such as the latency SLO.
For example: "The service must sustain 7,000 redirects per second at peak while keeping 99% of redirects under 100 ms. Load is expected to grow 5x within 12 months."
Dimensions of load
Different systems grow in different ways. Name the dimension before you choose a design, because each one stresses a different component.
| Load dimension | Example | Component under pressure |
|---|---|---|
| Request rate | Redirects per second | Web servers, cache |
| Data volume | Billions of stored URLs | Database storage, indexes |
| Concurrent connections | Open streaming sessions | Connection limits, memory |
| Fan-out | One post delivered to a million followers | Queues, write amplification |
A system can scale well on one dimension and badly on another. A URL shortener handles read growth easily with caches, but a growing data set still strains one database.
Vertical and horizontal scaling
Vertical scaling means moving to a bigger machine. It is simple, but it has a ceiling and a single machine remains a single point of failure. Horizontal scaling means adding more machines behind a load balancer. It has no fixed ceiling, but it requires the application to run on many nodes at once.
A requirement can force the choice. If it says "no downtime during capacity changes", horizontal scaling is the natural fit, because you can add nodes while the others keep serving.
Checking a scalability target
Turn the growth target into numbers before you design. This sketch reuses the load estimate from the capacity chapter and applies a growth factor.
average_rps = 2315
peak_factor = 3
growth = 5
per_server_rps = 1000
peak_now = average_rps * peak_factor
peak_future = peak_now * growth
servers_now = -(-peak_now // per_server_rps) # ceiling division
servers_future = -(-peak_future // per_server_rps)
print(peak_now, servers_now) # 6945 7
print(peak_future, servers_future) # 34725 35The result says that a 5x growth target needs about 35 servers instead of 7, assuming each server handles 1,000 requests per second. In practice, add headroom so servers do not run at 100% utilization.
Common errors
- Writing "highly scalable" with no load number or growth period.
- Stating growth without the quality that must hold, so latency may degrade while the system technically "handles" the load.
- Sizing only for average load and ignoring the peak factor.
- Assuming that adding servers always raises throughput. A shared database or lock can cap it.
Exercise
A requirement says "The system must be scalable." Rewrite it as a testable scalability requirement for a service that currently peaks at 2,000 requests per second, and name one component that might limit it.
Show answer
For example: "The service must sustain 10,000 requests per second at peak, a 5x increase, within 12 months, while keeping 99% of requests under 200 ms." It names the load dimension (request rate), the growth target (5x in 12 months) and the quality that must hold (p99 latency). A likely limit is the shared database, which does not scale just by adding web servers.