Sub topic 2
How systems fail and where single points of failure hide
This chapter assumes you know the basics of client-server architecture, what a load balancer and DNS do, and how timeouts and health checks work. It also assumes you can read the availability numbers from the previous chapter. Here you will learn how components fail and how to find the parts of a design that can take the whole service down.
How components fail
A failure is not always a crash. Different failure types need different defenses.
| Failure mode | What it looks like | Why it is hard |
|---|---|---|
| Crash | The process or host stops | Easy to detect, since connections are refused |
| Hang | The process runs but never answers | Looks alive to a simple port check |
| Slow | Responses take seconds instead of milliseconds | Callers time out and retry, which adds load |
| Partial | Some requests or some users fail | Averages hide it |
| Wrong answer | Corrupt or stale data is returned | No error is raised at all |
| Network partition | Nodes are alive but cannot reach each other | Each side believes the other is dead |
Hangs and slow responses are the most damaging in practice. A crashed server is removed from rotation quickly. A slow server keeps receiving traffic and holds connections open until callers run out of threads.
What a single point of failure is
A single point of failure (SPOF) is any component whose failure stops the whole service. Redundancy only helps if you know where to add it, so finding SPOFs comes first.
The obvious SPOF is a lone database or one load balancer. The hidden ones are more dangerous:
- Shared dependencies. Three app servers that all read one configuration service are only as available as that service.
- Shared infrastructure. Replicas on the same rack, power feed, or hypervisor fail together.
- Control-plane dependencies. A failover system that needs a working DNS provider or credentials service to act can be blocked by that dependency.
- Single credentials. One expiring TLS certificate or API key takes every replica down at once.
- People and process. One person holds the deploy keys, or a runbook exists only on a wiki that is hosted in the failed region.
The load balancers and app servers are duplicated. The config service and the database are not, so each is a SPOF.
Finding SPOFs in a design
List each layer of the request path, list the replicas in each layer, and list what each replica needs to run. A layer has a SPOF if it has one replica, or if every replica needs the same thing.
layers = {
"load balancer": {"lb-1": ["rack-A"], "lb-2": ["rack-B"]},
"app": {
"app-1": ["rack-A", "config-svc"],
"app-2": ["rack-B", "config-svc"],
},
"database": {"db-1": ["rack-A"]},
}
def single_points(layers):
found = []
for layer, replicas in layers.items():
if len(replicas) == 1:
found.append((layer, next(iter(replicas))))
continue
shared = set.intersection(*(set(needs) for needs in replicas.values()))
for dep in sorted(shared):
found.append((layer, dep))
return found
for layer, name in single_points(layers):
print(f"{layer}: {name}")This prints app: config-svc and database: db-1. The check is a simplified model, but the questions it asks are the ones to ask in a design review: how many copies are there, and what do all the copies share?
Common mistakes
- Counting replicas without checking what they share.
- Assuming a failure is a crash, and testing only that case.
- Ignoring the failover mechanism itself. A single health-checker or a single DNS provider is a SPOF.
- Treating a rarely used backup path as proven. A copy that has never carried traffic may not work.
Exercise
A service has three app servers on three different racks. All three authenticate users through one identity service with a single instance. Is there a SPOF, and what failure mode would be hardest to detect if the identity service degraded?
Show answer
Yes, the identity service is a SPOF, because every replica needs it. The hardest case is a slow identity service. It still accepts connections, so a port check passes, but logins time out and the app servers tie up threads waiting on it.