Back to articles
Health Check Endpoints: Beyond Simple Pings
NewsDevOps

Health Check Endpoints: Beyond Simple Pings

via Dev.to DevOpsYoung Gao

Your /health endpoint returns 200. Your database is down. Your load balancer keeps routing traffic to a broken server. Three Types of Health Checks Liveness : Is the process alive? Return 200 if the server can respond at all. Kubernetes uses this to decide whether to restart your pod. Readiness : Can the process serve traffic? Check database, cache, and critical dependencies. Kubernetes uses this to decide whether to route traffic. Startup : Is the app done initializing? Prevents premature liveness checks from killing a slow-starting container. Implementation interface HealthCheck { name : string ; check : () => Promise < { status : " up " | " down " ; latency : number } > ; } const checks : HealthCheck [] = [ { name : " database " , check : async () => { const start = Date . now (); try { await pool . query ( " SELECT 1 " ); return { status : " up " , latency : Date . now () - start }; } catch { return { status : " down " , latency : Date . now () - start }; } }}, { name : " redis " ,

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
5 views

Related Articles