HA & DR — Fundamentals
HA vs. DR — Core Concepts
| High Availability (HA) | Disaster Recovery (DR) |
|---|
|---|---|---|
| Scenario | Pod crashes, node fails, AZ down | Entire region unavailable |
|---|---|---|
| Goal | Zero downtime during partial failure | Recover from total failure |
| RTO | Seconds to minutes | Minutes to hours |
| Solution | Multiple replicas, anti-affinity, PDB | Multi-region, backups, runbooks |
| Cost | Medium (+50-100% infra) | High (+100-200% infra for active-passive) |
HA in Kubernetes
Readiness probes control whether a pod receives traffic; liveness probes control whether Kubernetes restarts the pod. Conflating them — using the same shallow check for both — means a pod stuck waiting on a slow dependency gets killed and restarted (liveness) instead of just being pulled from the load balancer until it recovers (readiness), which is usually the wrong response.
Database HA
Disaster Recovery
DR tiers:
| Strategy | RPO | RTO | Cost | Use when |
|---|
|---|---|---|---|---|
| Active-Active | ~0 | ~0 | 2x | RTO/RPO requirements are seconds |
|---|---|---|---|---|
| Active-Passive (warm) | Minutes | 5-15 min | 1.5x | Business-critical, can afford 15 min downtime |
| Backup + Restore | Hours | 1-4 hours | 1.1x | Non-critical, cost-sensitive |
A DR runbook needs to be a genuinely followable, step-by-step document — who declares a disaster, who has the authority to trigger failover, the exact commands to run in order, and how to verify the failover actually succeeded — tested via periodic DR drills, not written once and assumed correct. Chaos engineering (deliberately triggering a controlled failure and confirming the DR/HA response actually works as designed) is the practical way to validate a runbook actually works before a real disaster is the first time it's tried.
Interview Questions
What is the difference between RTO and RPO? Give a concrete example.
RTO (Recovery Time Objective) is the maximum acceptable time your system can be down after a failure — it answers "how long until we must be back online?" RPO (Recovery Point Objective) is the maximum acceptable amount of data that can be lost — it answers "how old can our last good backup be?" Concrete example: a payment processing system where the business decides it cannot afford to be down more than 15 minutes (RTO=15min) and cannot lose more than 1 minute of transaction data (RPO=1min). These requirements directly drive architecture: an RTO of 15 minutes means a warm standby that can be promoted quickly is needed, not a cold backup taking 2 hours to restore. An RPO of 1 minute means synchronous or near-synchronous replication is needed — daily backups alone would give an RPO of 24 hours, far outside the requirement. Lower RTO and RPO always mean higher infrastructure cost — a system with RTO=0 and RPO=0 (no downtime, no data loss) requires active-active multi-region architecture, which is genuinely expensive. RTO and RPO should be chosen based on the actual business impact of downtime versus the real cost of the HA infrastructure needed to hit them, not set arbitrarily to "as low as possible."
How do you design a highly available application on Kubernetes?
HA in Kubernetes requires several layers working together, not any single setting. Run at least 3 replicas (not 2 — with 2, losing 1 during a rolling update or node failure leaves zero redundancy at that moment), spread across multiple nodes and AZs via pod anti-affinity and topology spread constraints, so a single node or AZ failure can't take out multiple replicas simultaneously. Configure a PodDisruptionBudget so voluntary disruptions (node drains, cluster upgrades) never reduce available replicas below a safe minimum. Use genuinely meaningful readiness and liveness probes — a readiness probe checking real downstream dependency health (not just "is the process running") ensures traffic only routes to pods that can actually serve it, while a liveness probe restarts genuinely stuck processes without over-aggressively killing pods still recovering from a slow dependency. For the data layer, use a managed database with Multi-AZ automatic failover (RDS Multi-AZ) or a self-managed replication setup with a tested, practiced promotion procedure — application-layer HA alone doesn't help if the database itself is a single point of failure.

