AlgoViz

Tech stacks for high availability

medium 30 min

The 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

UsersPod 2

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

Our systemUsersLoad balancerZone 1 pods50%Zone 2 pods50%Zone 3 pods50%
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

    critical

    The part that protects the servers has no protection itself.

    Wrong
    haproxy = [machine_1]
    Right
    haproxy = [machine_1, machine_2]   # shared address# or one managed balancer in three zones
  • Liveness that checks the database

    critical

    A slow database restarts all pods, again and again.

    Wrong
    livenessProbe = {"path": "/health/deep"}
    Right
    livenessProbe = {"path": "/healthz"}   # this process onlyreadinessProbe = {"path": "/ready"}
  • Turning off synchronous_commit for async replicas

    major

    It makes the primary itself confirm before the log is on disk. Replication mode is a different setting.

    Wrong
    synchronous_commit = "off"
    Right
    synchronous_mode = True    # in Patroni, for no loss# or leave it off for asynchronous copies
  • Trusting a disruption budget with crashes

    major

    It only refuses voluntary evictions. A dead node does not ask.

    Wrong
    budget(min_available="50%")   # "so we are safe"
    Right
    budget(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.