Reliability, availability and scalability
Overview
Functional requirements say what a system does. Non-functional requirements say how well it must do it, and they drive most design decisions. This lesson covers the three you’ll discuss in almost every interview: reliability, availability and scalability.
Three words that are often mixed up
- Reliability: the system does the right thing, even when parts fail. A reliable payment system never charges twice, even during a crash.
- Availability: the system is up and answering requests. Measured as the percentage of time (or of requests) that succeed.
- Scalability: the system can handle more load by adding resources, without a redesign.
A system can be available but unreliable (it answers quickly, with wrong data) or reliable but unavailable (it refuses to answer rather than risk a wrong answer). Weeks 5 and 6 return to that tension.
Counting the nines
Each extra nine cuts allowed downtime by ten. Four nines leaves less than five minutes a month, which is less time than it takes a person to notice an alert, open a laptop and investigate. That’s why high availability needs automation (health checks, automatic failover), not heroics.
Higher isn’t automatically better. Each nine costs much more money and engineering effort, so pick the target the business needs. An internal reporting tool might be fine at 99.5%; a payment API might need 99.99%.
The maths of failure
Two rules let you estimate the availability of a design.
In series, multiply. If a request needs the load balancer and the app and the database, all must be up:
0.999 × 0.999 × 0.999 ≈ 0.997 (99.7%)Every extra dependency in the path lowers availability. A chain of ten 99.9% services is only about 99%.
In parallel, multiply the failure chances. If either of two independent copies can serve the request, the tier fails only when both fail:
1 − (1 − 0.99)² = 1 − 0.0001 = 0.9999 (99.99%)Two mediocre copies beat one excellent machine. That’s the core idea behind redundancy, with an important caveat: the copies must fail independently. Two servers in the same rack share power and a network switch; two copies running the same buggy release will crash together.
Removing single points of failure
A single point of failure (SPOF) is any component whose failure takes the whole system down. Finding SPOFs is a standard interview step. Walk through your diagram box by box and ask “what happens if this dies?”:
- One app server → run several behind a load balancer.
- One load balancer → run a pair, with a floating IP or DNS failover.
- One database → add replicas and automatic failover.
- One data centre → spread across availability zones, and for critical systems, regions.
Scaling up vs scaling out
- Vertical scaling (scale up): move to a bigger machine. It needs no code changes and is often the right first step, especially for databases. But there’s a ceiling, big machines get expensive fast, and it’s still one machine.
- Horizontal scaling (scale out): add more machines and spread the load. It grows much further and survives failures, but needs stateless servers, a load balancer and, for data, a way to split or copy it.
Most real systems do both: scale app servers out, scale the database up as far as is sensible, then add replicas and shards.
Measuring it: SLIs, SLOs and SLAs
Teams make these goals concrete with three terms:
- SLI (service level indicator): a metric you measure, such as “percentage of requests that return 2xx within 300 ms”.
- SLO (service level objective): your internal target for the SLI, such as “99.9% over 30 days”.
- SLA (service level agreement): a contract with customers, with penalties such as refunds if you miss it. SLAs are set looser than SLOs so you have a safety margin.
The gap between 100% and the SLO is the error budget. With a 99.9% monthly SLO you may “spend” about 43 minutes of failure. If the budget is healthy, ship features faster; if it’s used up, slow down and invest in reliability.
Other “-ilities” to mention
You’ll often add a few more non-functional requirements:
- Durability: once data is saved, it isn’t lost (object stores advertise eleven nines of durability).
- Consistency: whether every reader sees the latest write (week 5).
- Latency: for example p99 under 200 ms (previous lesson).
- Cost, security and maintainability.
In an interview, ask about scale and availability early, write the targets on the board and refer back to them when you justify choices.
Recap
Reliability is doing the right thing, availability is being up, and scalability is handling growth by adding resources. Availability is counted in nines; dependencies in series multiply it down, while independent redundant copies push it up. Remove single points of failure, scale app servers out, and state targets as SLOs with an error budget.
How available is it?
A checkout request passes through a load balancer (99.99% available), an app tier (99.95%), and a single database (99.9%). (a) What is the availability of the whole path? (b) How much downtime per month does that allow, roughly? (c) The database is the weak spot. If you add a standby that takes over when the primary fails, and you treat the two copies as independent, what does the database tier become? (d) Name two reasons the real number would be lower than your answer to (c).
(a)
(b)
(c)
(d)(a) In series, multiply: 0.9999 x 0.9995 x 0.999 = about 0.9984, so 99.84%.
(b) A month has about 730 hours. 0.16% of 730 h = about 1.2 hours (~70 minutes)
of downtime per month.
(c) Redundant copies: 1 - (1 - 0.999)^2 = 1 - 0.000001 = 99.9999% for the database tier.
The whole path becomes 0.9999 x 0.9995 x 0.999999 = about 99.94%.
(d) - Failover isn't instant: detecting the failure and promoting the standby takes
seconds to minutes, which counts as downtime.
- Failures aren't independent: both copies may share a data centre, a network,
a power supply, or the same bad deploy or bad query.
- The failover mechanism itself can fail or cause a split brain.Summary
- Reliability means working correctly; availability means being up and reachable; scalability means handling growth by adding resources.
- Availability is measured in nines: 99.9% allows about 8.8 hours of downtime per year, 99.99% about 53 minutes.
- Components in series multiply their availabilities; redundant copies multiply their failure chances, so redundancy removes single points of failure.
- Vertical scaling makes one machine bigger; horizontal scaling adds machines and needs stateless servers and a load balancer.
- SLIs are what you measure, SLOs are your targets, and SLAs are promises to customers with penalties.