← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Health Check Patterns

observability Beginner

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'];
});

Added 23 Mar 2026
Views 36
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 2 pings S 1 ping S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 3 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T
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
crawler 32 crawler_json 1 pre-tracking 2
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

✓ schema.org compliant