Skip to content

Gateway: async healthcheck handler and explicit readiness probe timeout - #865

Closed
lorenzo-norcini-scale wants to merge 1 commit into
mainfrom
lorenzonorcini/gateway-readyz-async-probe-timeout
Closed

Gateway: async healthcheck handler and explicit readiness probe timeout#865
lorenzo-norcini-scale wants to merge 1 commit into
mainfrom
lorenzonorcini/gateway-readyz-async-probe-timeout

Conversation

@lorenzo-norcini-scale

@lorenzo-norcini-scale lorenzo-norcini-scale commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

What

  • healthcheck (serving /healthcheck, /healthz, /readyz) is now async def. As a sync handler it was dispatched to the shared anyio threadpool, so under load the readiness probe queued behind blocked requests and timed out while the app container was healthy.
  • The gateway readinessProbe now sets an explicit timeoutSeconds (default 5, configurable via gateway.readinessProbeTimeoutSeconds). Previously unset, which means the Kubernetes default of 1s.

Why

During the 2026-08-13 gateway incident, saturated but healthy pods failed the 1s probe and were ejected from the Service, concentrating load on the remaining pods (11 of 60 Ready at the worst point while ~40 app containers were healthy). The two changes remove that ejection mechanism: the probe no longer competes with request handling for threadpool slots, and the timeout tolerates transient event-loop delay.

Notes

  • No livenessProbe is added. Restarting a saturated pod discards its in-flight work and worsens overload; readiness gating plus the existing container restart policy remain the failure handling.
  • Rendered chart verified: probe emits timeoutSeconds: 5 with default values.

🤖 Generated with Claude Code

Greptile Summary

The PR moves the gateway health endpoints onto the async request path and gives Kubernetes readiness probes a configurable five-second timeout.

  • Converts the shared /healthcheck, /healthz, and /readyz handler to async def.
  • Adds gateway.readinessProbeTimeoutSeconds to the Helm values.
  • Renders the configured timeout into the gateway Deployment readiness probe.

Confidence Score: 5/5

The PR appears safe to merge, with the async handler and Helm timeout remaining aligned with the existing gateway readiness contract.

The registered health routes are awaited by the ASGI execution path, remain exempt from the application concurrency limiter, and the chart renders a valid five-second readiness timeout from its default values.

Important Files Changed

Filename Overview
charts/model-engine/templates/gateway_deployment.yaml Adds the configured readiness timeout to the gateway probe without changing its path, cadence, or failure threshold.
charts/model-engine/values.yaml Introduces a documented five-second default for the gateway readiness timeout.
model-engine/model_engine_server/api/app.py Makes the minimal health handler asynchronous so FastAPI executes it on the event loop rather than the shared worker threadpool.

Reviews (1): Last reviewed commit: "fix(gateway): async healthcheck handler ..." | Re-trigger Greptile

Context used:

…meout

A sync healthcheck handler runs in the anyio threadpool, so under load the
/readyz probe queues behind blocked requests, misses the 1s default probe
timeout, and k8s ejects pods that are saturated but healthy. Making the
handler async keeps the probe on the event loop, and the probe timeout is
now explicit (default 5s) and values-configurable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lorenzo-norcini-scale

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated incident-hardening PR: see the PR referencing this one.

@lorenzo-norcini-scale

Copy link
Copy Markdown
Collaborator Author

Superseded by #868.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant