High Availability
High availability means surviving failures invisibly: machine loss, AZ loss, dependency brownouts, and the human deploy at 17:00 on Friday.
Introduction
High availability means surviving failures invisibly: machine loss, AZ loss, dependency brownouts, and the human deploy at 17:00 on Friday. TechLearningPRO Orders aims for redundant pods across zones, correct readiness/liveness probes, automated DB failover where the platform supports it, and graceful shutdown that drains in-flight checkouts.
HA is redundancy + health checks + failover + practice. Runbooks linked from every alert beat heroics. Retries use jittered backoff so Orders does not become a thundering herd against Postgres or Inventory.
Boot 3 Actuator health groups feed Kubernetes probes; Java 21 does not change the ops math. Multi-region is for tier-0 when RPO/RTO demand it — not a default for every service.
This lesson closes the production/enterprise arc with failure-first thinking.
Purpose of this lesson
Design Orders for HA: multi-AZ replicas, correct probes, graceful shutdown, failover, and practiced runbooks.
Understanding the topic
Survive failure without users noticing.
- Redundancy: N replicas, multi-AZ; multi-region for tier-0.
- Health checks: readiness vs liveness done right.
- Load balancing: least-connections; sticky only when forced.
- Failover: primary/replica DB with automatic promotion where offered.
- Graceful shutdown: drain connections; finish in-flight requests.
- Retries: jittered backoff — never thundering-herd.
- Runbooks: every alert links to one; game-day practice.
Step-by-step explanation
- Deploy Orders with at least two replicas across AZs.
- Wire readiness to dependency health (DB) and liveness to process health — do not restart on downstream blips.
- Enable graceful shutdown (
server.shutdown=graceful) with a drain period that matches the LB. - Attach runbooks to latency/error alerts; schedule a game day that kills a pod and a DB failover.
Informative example
HA-oriented Boot 3 + Kubernetes probes for Orders.
# application.ymlserver:shutdown: gracefulspring:lifecycle:timeout-per-shutdown-phase: 30smanagement:endpoint:health:probes:enabled: truehealth:livenessstate:enabled: truereadinessstate:enabled: true# Deployment probeslivenessProbe:httpGet: { path: /actuator/health/liveness, port: 8080 }periodSeconds: 10readinessProbe:httpGet: { path: /actuator/health/readiness, port: 8080 }periodSeconds: 5terminationGracePeriodSeconds: 40
Real-world use
A rolling deploy once killed Orders pods mid-checkout because shutdown was immediate and readiness never went false. Enabling graceful shutdown and separating readiness from liveness stopped 502 spikes; a later game day proved DB failover runbooks before a real AZ incident.
Security implications
HA controls must not weaken isolation during failover.
- Failover targets use the same least-privilege credentials — rotated via the secret store.
- Health endpoints stay non-sensitive; detailed health only when authorized.
- Do not disable auth during incidents 'to keep the site up'.
Best practices
- Redundancy in every critical tier — app, LB, data.
- Practice failure (game days) before production teaches you.
- Link every alert to a runbook with owners and rollback steps.
Common mistakes
- Using the same probe for liveness and readiness and restarting pods on DB blips.
- Single-replica 'HA' PowerPoint architectures.
- Retries without jitter that amplify outages.
Advanced interview questions
Interview Prep
Practice concise answers, then expand each card for the explanation.
1BeginnerQuestionWhat is the difference between liveness and readiness?+
Answer
2IntermediateQuestionWhy is graceful shutdown required for HA deploys?+
Answer
3IntermediateQuestionWhy practice game days?+
Answer
Hands-on exercise
Lab. Configure graceful shutdown and distinct liveness/readiness probes on Orders. Kill one pod under load and confirm the LB stops sending traffic before process exit; write a half-page runbook for that alert.
Summary
High availability keeps TechLearningPRO Orders up when pieces fail. You now have the production and enterprise architecture toolkit to operate Boot 3 services with confidence.