Tech stacks for high availability
medium 30 minThe products that do the jobs of high availability, layer by layer: DNS and CDN, load balancers, application replicas, caches and databases.
See it run
The layers of a stack, what each product does when something fails, and what they promise together.
Operations
Build the stack
Five layers from the name lookup to the data, each with its own way to survive.
Step 1 of 5
One app
No spare anywhere
Users reach one pod directly. Nothing has a spare.
Step 1: One app
stack = [ ("dns", "many locations"), ("balancer", "pair or managed"), ("app", "replicas in zones"), ("cache", "replica, or refill"), ("database", "replica and leader"),]- Recovery
- Layer by layer
- You run
- Five products
- Stateless
- more copies
- Stateful
- replicas, a leader
For every box say two things: what happens when it dies, and how long that takes.
In the real world
The same tech stacks for high availability doing real jobs. Pick one and step through it.
Three zones, one power failure, and the question of room.
Step 1 of 3
Normal
- Load per working zone
- 50%
Room to spare
Every zone carries a third of the traffic, and half of what it could.
Step 1: Normal
Common mistakes
The bugs interviewers watch for, with the fix beside each.
One load balancer
criticalThe part that protects the servers has no protection itself.
Wronghaproxy = [machine_1]Righthaproxy = [machine_1, machine_2] # shared address# or one managed balancer in three zonesLiveness that checks the database
criticalA slow database restarts all pods, again and again.
WronglivenessProbe = {"path": "/health/deep"}RightlivenessProbe = {"path": "/healthz"} # this process onlyreadinessProbe = {"path": "/ready"}Turning off synchronous_commit for async replicas
majorIt makes the primary itself confirm before the log is on disk. Replication mode is a different setting.
Wrongsynchronous_commit = "off"Rightsynchronous_mode = True # in Patroni, for no loss# or leave it off for asynchronous copiesTrusting a disruption budget with crashes
majorIt only refuses voluntary evictions. A dead node does not ask.
Wrongbudget(min_available="50%") # "so we are safe"Rightbudget(min_available="50%")spread(pods, over=["zone", "hostname"])
Interview tips
How to explain it
- Walk from DNS to disk.
- Say stateless or stateful for each layer.
- Name the failover and its time.
Memory trick: STACK
- Services, managed by the cloud.
- Traffic, Application, Cache.
- Keep data: replication.
Good defaults
- Managed balancer, three zones.
- Pods with spread, budget and two honest probes.
- Multi-AZ database, failover tested.
Watch out for
- Promises above the database's own.
- A cache that must not be empty.
- Secrets inside configuration files.