Sub topic 4
Fault domains: making sure copies do not fail together
This chapter assumes you know what redundancy is (spare copies of a component) and how availability is calculated for components in series and in parallel. It also assumes basic familiarity with hosts, racks, networks, and cloud regions. By the end you should be able to name the fault domains a service sits in, check whether its copies share one, and place copies so that one failure cannot take them all down.
Why copies are not enough
The parallel formula from the availability chapter gives two 99% components a combined availability of about 99.99%. That result depends on an assumption: the components fail independently. Two copies fail independently only if nothing sits underneath both of them that can break.
Two copies on one physical host both stop when the host loses power. Two copies behind one network switch both become unreachable when the switch fails. In these cases you have two copies and one failure, so you do not have redundancy.
A fault domain is a set of components that can fail together because they share a dependency. The dependency might be a power supply, a switch, a building, a software version, or a configuration file. Redundancy only works when the copies sit in different fault domains for the failures you care about.
The usual hierarchy
Fault domains nest. A host sits in a rack, a rack in a data center, and a data center in a region.
| Domain | Typical shared dependency | Typical failure |
|---|---|---|
| Process | Memory, code path | Crash, memory leak, deadlock |
| Host | Hardware, operating system | Disk or power supply failure, kernel panic |
| Rack | Top-of-rack switch, power strip | Switch failure, tripped breaker |
| Zone (data center) | Building power, cooling, core network | Power outage, cooling failure, fiber cut |
| Region | Metro network, regional control plane | Regional service outage, natural disaster |
| Provider or account | Billing, identity, API | Suspended account, provider-wide incident |
The cost of spreading rises as you go up. Two hosts in one rack are cheap and add no latency. Two regions cost more and add tens of milliseconds, and they make data replication harder. Choose the level that matches the failures you need to survive and can afford.
Blast radius
The blast radius is the share of your capacity or users that one failure affects. For a given domain level, it is the largest number of copies that share one domain, divided by the total.
If six replicas run in one zone, the zone's blast radius is 100%. Three replicas in each of two zones give 50%. Two in each of three zones give about 33%. A smaller blast radius is better, but you also need enough remaining capacity to carry the load after a domain is lost. This is the N+1 idea from the topologies chapter, applied to domains. With three zones, each zone must be able to lose itself and still leave two zones that can handle the full load.
Dependencies you cannot see on a diagram
Physical location is the obvious domain. Many real outages come from logical domains that don't appear on a rack diagram.
- Software version. If every replica runs the same build, one bug in that build, such as a bad date parse, crashes them all at once.
- Configuration and deployment. A bad config pushed to all replicas at once makes the deployment pipeline a fault domain.
- Shared services. Replicas that all depend on one DNS resolver, one authentication service, or one certificate authority fail together when it does.
- Time. An expired certificate or a leap-second bug hits every copy at the same moment.
- Shared quota or account limits. All copies can hit one API rate limit or capacity limit together.
- Control plane. Data plane copies may be independent while the system that restarts or reconfigures them is not.
You handle logical domains differently from physical ones. You spread physical copies across locations. You spread logical risk with staged rollouts (a few replicas first, then more), version diversity during upgrades, and independent dependencies for critical paths.
Putting a number on correlation
You can fold a shared domain into the availability math. Treat the domain as a component in series with the copies that depend on it. Then use the parallel formula for the copies.
def series(*availabilities):
result = 1.0
for a in availabilities:
result *= a
return result
def parallel(*availabilities):
all_down = 1.0
for a in availabilities:
all_down *= (1.0 - a)
return 1.0 - all_down
instance = 0.99
zone = 0.999
# Both instances in one zone: the zone is in series with the pair.
same_zone = series(zone, parallel(instance, instance))
# One instance per zone: each path is zone + instance, and the paths are in parallel.
path = series(zone, instance)
two_zones = parallel(path, path)
print(round(same_zone, 5)) # 0.9989
print(round(two_zones, 5)) # 0.99988Same-zone placement is capped by the zone's own 99.9%. The pair of instances is almost perfect, but the zone is not. Spreading the instances across two zones raises availability from about 99.89% to about 99.99%. This gain comes from placement alone, with no extra hardware.
Checking placement in code
You can audit placement automatically. The script below takes a list of replicas with their location at each level and reports the blast radius per level. It also flags levels where all replicas share one domain.
from collections import Counter
LEVELS = ["host", "rack", "zone"]
replicas = {
"app-1": {"host": "h1", "rack": "r1", "zone": "a"},
"app-2": {"host": "h2", "rack": "r1", "zone": "a"},
"app-3": {"host": "h3", "rack": "r2", "zone": "b"},
}
def audit(replicas, levels):
total = len(replicas)
for level in levels:
counts = Counter(r[level] for r in replicas.values())
worst_domain, worst_count = counts.most_common(1)[0]
share = worst_count / total
status = "SPOF" if worst_count == total else "ok"
print(f"{level:5} worst={worst_domain} share={share:.0%} {status}")
audit(replicas, LEVELS)
# host worst=h1 share=33% ok
# rack worst=r1 share=67% ok
# zone worst=a share=67% okHere no level is a total single point of failure, but losing zone a removes two of three replicas. Whether that is acceptable depends on whether the single remaining replica can carry the load.
Enforcing spread in practice
Most platforms let you declare placement instead of hoping for it. Examples include anti-affinity rules in a scheduler, spread constraints in Kubernetes, placement groups or availability zone lists in cloud autoscaling, and rack awareness in storage systems such as HDFS and Cassandra.
Declare the rule, then verify the result. Schedulers treat many spread rules as preferences and place copies together when capacity is tight. Some rules are hard requirements, which leave a copy unscheduled instead of breaking the rule. Know which kind you configured.
Common errors
- Counting copies, not domains. "We have three replicas" says nothing about whether they share a rack. Always ask what the copies have in common.
- Spreading compute but not data. The application servers span three zones, but they all use one database in one zone. The database zone is then the real domain for the whole service.
- Two zones with no capacity headroom. If each zone runs at 70% load, losing one zone pushes the other to 140%. Spread also needs spare capacity, or the survivors fail from overload.
- Hidden shared dependencies. Replicas in separate zones may all use one DNS provider, one secrets store, or one deployment tool. Trace the full dependency chain of each copy.
- Uniform change. Deploying the same change to every copy at once turns the deploy into a shared domain. Roll out in stages.
- Ignoring the control plane. If recovery requires an API in the failed region, you cannot recover while it is down.
- Confusing zone with independence. Zones in one region reduce power and facility risk. They usually share a regional control plane, so a regional incident can still affect all of them.
Choosing the level
Start from the failure you must survive.
- Surviving a single host or rack failure: spread across hosts and racks. Cost and latency stay low.
- Surviving a data center outage: use at least two zones, and three if you need quorum (covered in a later chapter) or want to keep redundancy after losing one.
- Surviving a regional outage or a provider-level event: use multiple regions or providers. Expect higher cost, replication lag, and more operational work.
Each step up the hierarchy covers more failures and costs more. Many services stop at the zone level, because regional failures are rare compared with the cost of running across regions.
Exercise
A service runs four replicas, two in zone A and two in zone B. Each zone is at 60% of its capacity limit under normal load, and each replica uses the same share. A power failure takes down zone A. What happens, and what change would you make?
Show answer
Zone B must now carry all the traffic. Its load rises to 120% of capacity (60% from its own replicas plus 60% moved over from zone A), so the survivors overload and may fail too, turning a partial outage into a full one. Reduce per-zone load so one zone can carry everything (each zone at or below 50%), or add a third zone so each of the three runs at no more than about 67% and two zones can carry the full load after one fails.