Sub topic 4
Fault domains: making sure copies do not fail together
This chapter assumes you know what redundancy is, how to compute series and parallel availability, and what a single point of failure is. It builds on the earlier chapter on redundancy.
Why copies are not enough
The parallel formula from the availability chapter assumes failures are independent. Two 99% components in parallel give about 99.99% only if one failing tells you nothing about the other.
Copies often fail together because they share something. Two servers on the same rack share a power feed and a network switch. If the switch dies, both servers are unreachable, and the real availability is close to that of the switch alone.
A fault domain is a set of components that can fail together because they share a dependency. Redundancy only helps when the copies sit in different fault domains.
The usual hierarchy
Fault domains nest. Each level up covers a larger blast radius, which is the amount of your system a single failure can take down.
| Level | Shared dependency | Typical cause of failure |
|---|---|---|
| Process | Memory, one runtime | Crash, memory leak |
| Host | Hardware, operating system | Disk failure, kernel panic |
| Rack | Power feed, top-of-rack switch | Switch failure, breaker trip |
| Zone | Building, cooling, local network | Power loss, cooling failure |
| Region | Geography, regional control plane | Natural disaster, regional network fault |
In the diagram, hosts 1 and 2 share rack A1. Losing that rack removes both. Hosts 1 and 4 share only the region, so only a regional failure removes both.
Spreading copies across domains
Pick the level of domain you want to survive, then place copies in separate domains at that level.
- To survive a host failure, run copies on different hosts.
- To survive a rack failure, put copies in different racks.
- To survive a zone failure, put copies in different zones.
- To survive a regional failure, put copies in different regions.
Each step up costs more. Cross-zone traffic adds latency and often a data transfer charge. Cross-region replication adds tens to hundreds of milliseconds and forces you to choose between synchronous and asynchronous replication, which a later chapter covers.
Choose the level from the failures you must tolerate and the cost you can accept. Many services stop at multiple zones in one region, because zone failures are far more common than regional ones.
Hidden shared dependencies
The common error is placing copies in different obvious domains while they still share something less visible.
- A shared database or message queue behind many stateless servers.
- A single DNS provider or certificate authority.
- A shared deployment pipeline that pushes the same bad release to every copy.
- A shared configuration service, secret store, or clock source.
- Identical software versions, which means one bug hits every copy at once.
These are called correlated failures. A bad release is a good example: it ignores your zone layout entirely. Staged rollouts, where you deploy to one domain first and wait, treat the deployment itself as a fault domain.
Checking your placement
Many platforms let you label where a copy runs and then require spreading. The Kubernetes example below asks the scheduler to keep replicas evenly spread across zones.
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
replicas: 3
selector:
matchLabels:
app: app
template:
metadata:
labels:
app: app
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: app
containers:
- name: app
image: example/app:1.0With maxSkew: 1, the number of replicas in any two zones differs by at most one. DoNotSchedule leaves a replica pending instead of placing it in a crowded zone.
Exercise
Three replicas of a service run on three different hosts, all in one rack. Each host is 99% available and the rack switch is 99.9% available. Roughly what availability can the service reach, and what is the fix?
Show answer
The service cannot exceed the rack switch's availability, about 99.9%, because losing the switch removes all three hosts. The hosts in parallel are about 99.9999%, but the shared switch is in series with them. Move the replicas to different racks, or better, different zones, so no single switch or power feed removes all copies.