design-health-and-readiness-probes
Use when a load balancer or orchestrator needs liveness and readiness signals — splits the two endpoints, keeps liveness dependency-free, and makes readiness reflect actual ability to serve.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- design-health-and-readiness-probes
- description
- Use when a load balancer or orchestrator needs liveness and readiness signals — splits the two endpoints, keeps liveness dependency-free, and makes readiness reflect actual ability to serve.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md360 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Design health and readiness probes
Liveness asks "should this process be killed?"; readiness asks "should it take traffic?". Conflating them makes an orchestrator restart every pod during a dependency blip, or route to a pod that cannot serve.
Procedure
-
Expose two endpoints with distinct meanings: /healthz liveness: is the process itself alive and not wedged? /readyz readiness: can it serve a request right now?
-
Keep liveness cheap and dependency-free. It returns 200 as long as the event loop is responsive and must never call the database, cache or any peer. A liveness probe that fails when the database is down restarts every pod at once — the classic cascading restart.
-
Let readiness check only what is needed to serve: migrations applied, config loaded, warm cache, connection pool established. Leave peer health out unless the service is genuinely useless without it.
-
Configure with real timings and separate budgets: livenessProbe: { httpGet: {path: /healthz, port: 8080}, periodSeconds: 10, timeoutSeconds: 1, failureThreshold: 3 } readinessProbe: { httpGet: {path: /readyz, port: 8080}, periodSeconds: 5, timeoutSeconds: 2, failureThreshold: 2 } startupProbe: { httpGet: {path: /healthz, port: 8080}, periodSeconds: 2, failureThreshold: 30 }
-
Use a
startupProbefor slow boots so a slow start does not trip liveness and cause a restart loop; it gates the other probes until the app is up (here, up to 60 s). -
Return an accurate status code plus a small JSON body a human can read: {"status":"unready","reason":"migrations_pending","version":"a1b2c3"} Never return 200 with
{"status":"degraded"}— the orchestrator cannot read prose. -
Drain on shutdown: on SIGTERM flip
/readyzto 503 first, wait 5–10 s for the endpoint to leave the load balancer, then stop accepting, withterminationGracePeriodSecondsat least the in-flight drain time. -
Keep the probe handler off the request hot path and free of any lock a stuck request could hold, or the probe itself hangs and the pod is killed.
Pitfalls
- Readiness that probes the database: a 30 s database blip empties the endpoint list and turns a degradation into a full outage.
- Liveness with
failureThreshold: 1and a 1 s timeout, so one GC pause restarts every pod simultaneously. - A single endpoint serving both meanings, so you cannot restart without dropping traffic or drain without restarting.
- A readiness handler that always returns 200, so a rollout declares ready before the app can actually serve.
Verification
curl -s -o /dev/null -w '%{http_code}\n' localhost:8080/healthz # 200 while a dependency is stopped
curl -s -o /dev/null -w '%{http_code}\n' localhost:8080/readyz # 503 while it is stopped
kubectl get pods -w # READY only after readinessProbe passes, not before
Report: the two endpoints' semantics, the probe timings, and the observed behaviour — liveness stays 200 while a dependency is down, readiness flips 503→200 without any restart.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.