Reliability, availability and scalability

Topic 8 of 9 in Week 1: Foundations and the interview framework12 min readBeginnerFree course

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

Availability targets and the downtime they allow. 99% (two nines) allows 3.65 days per year or 7.3 hours per month. 99.9% (three nines) allows 8.77 hours per year or 43.8 minutes per month. 99.95% allows 4.38 hours per year or 21.9 minutes per month. 99.99% (four nines, highlighted) allows 52.6 minutes per year or 4.38 minutes per month. 99.999% (five nines) allows 5.26 minutes per year or 26.3 seconds per month. Components in series multiply: 99.9% times 99.9% times 99.9% is about 99.7%. Redundant copies combine: 1 minus (1 minus 0.99) squared is 99.99%.

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:

Text
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:

Text
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 versus horizontal scaling. Scaling up replaces a 4-CPU, 16 GB machine with one 64-CPU, 512 GB machine: simple and needs no code changes, but it has a hard ceiling and remains a single point of failure. Scaling out puts a load balancer in front of four 4-CPU, 16 GB machines: it grows almost without limit and survives failures, but needs stateless servers and a balancer.

  • 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.

Exercise

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).

Text
(a)
(b)
(c)
(d)

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.