Health Check Patterns
TL;DR
Health checks report service status to load balancers and orchestrators — /health/live (is the process running?), /health/ready (can it serve traffic?), and deep health checks for dependencies.
Explanation
Kubernetes probes: liveness (restart if failing), readiness (remove from load balancer if failing), startup (wait for slow start before liveness kicks in). Patterns: shallow (is process alive? just return 200), deep (check DB, cache, queue), readiness (are all dependencies ready?). Shallow for liveness — avoid cascading failures (if DB is down, all instances fail liveness, all restart, making DB situation worse). Deep for readiness — remove from rotation without restarting. Deep health check components: DB query (SELECT 1), cache ping, queue connectivity, disk space check, memory check. Timeout all checks (1-2s max).
Common Misconception
✗ Health check should verify all dependencies are working — use deep checks for readiness; use shallow checks for liveness. Deep liveness checks cause cascading failures when a dependency is down.
Why It Matters
Correctly implemented health checks are the foundation of zero-downtime deployments and automatic failure recovery — wrong probes cause unnecessary restarts or leave broken instances in rotation.
Common Mistakes
- Deep health check for liveness — DB down → all instances restart → thundering herd.
- No readiness probe — instances receive traffic before warming up.
- Health check without timeout — slow dependency causes health check to time out and restart healthy instance.
Code Examples
✗ Vulnerable
// Liveness checks DB — cascading failure on DB outage:
route('/health/live', function() {
DB::select('SELECT 1'); // DB down → liveness fails → instance restarts → more DB pressure
return ['status' => 'ok'];
});
✓ Fixed
// Shallow liveness — is process running?
route('/health/live', fn() => ['status' => 'alive']);
// Deep readiness — can serve traffic?
route('/health/ready', function() {
$checks = [
'db' => fn() => DB::select('SELECT 1'),
'cache' => fn() => Cache::has('health-check') || Cache::set('health-check', 1, 10),
];
foreach ($checks as $name => $check) {
try { $check(); } catch (Exception $e) {
return response(['status' => 'not ready', 'failed' => $name], 503);
}
}
return ['status' => 'ready'];
});
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
23 Mar 2026
Views
36
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 13
Perplexity 8
Unknown AI 4
Ahrefs 3
ChatGPT 2
Majestic 2
Google 2
Meta AI 1
Also referenced
How they use it
crawler 32
crawler_json 1
pre-tracking 2
Related categories
⚡
DEV INTEL
Tools & Severity
🟠 High
⚙ Fix effort: Low
⚡ Quick Fix
Separate /live (shallow, always fast) from /ready (deep, checks dependencies). Add startup probe for slow-starting services. Timeout all dependency checks at 1-2s.
📦 Applies To
web
cli
Laravel
Symfony
🔗 Prerequisites
🔍 Detection Hints
/health|healthcheck
Auto-detectable:
✗ No
⚠ Related Problems
🤖 AI Agent
Confidence: Low
False Positives: High
✗ Manual fix
Fix: Low
Context: File