Use health checks and connection draining
Remove failing instances carefully and let in-flight work finish.
- Distinguish liveness from readiness and explain draining and health-check hysteresis.
A liveness check asks whether a process should be restarted; a readiness check asks whether it should receive traffic. A shallow check can pass while a critical dependency is unavailable, while an overly deep check can eject every backend during a shared dependency outage. Thresholds, separate failure domains, and recovery hysteresis reduce flapping. During deploys, draining stops new connections while giving in-flight requests time to finish.
1states = ["ready", "draining", "removed"]
2for state in states:
3 accepts_new = state == "ready"
4 print(f"{state}: accepts_new={accepts_new}")ready: accepts_new=True draining: accepts_new=False removed: accepts_new=False
Real draining behavior depends on protocol and client behavior. Long-lived WebSockets or streaming responses may require a longer grace period or explicit reconnect logic.
Key takeaways
Liveness and readiness serve different purposes.
Avoid health checks that turn one dependency failure into total pool ejection.
Drain connections before planned removal when the protocol allows it.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…