Skip to main content

health_deep

Function health_deep 

Source
pub async fn health_deep(__arg0: State<Arc<AppState>>) -> impl IntoResponse
Expand description

Handles GET /health/deep — runs a tiny canary inference and returns 503 if the actual embedding pipeline is broken.

Unlike GET /health (which reads only in-memory atomics), this handler submits a real embed_dense call through the worker pool and exercises the full tokenize → ORT session.run() → projection path, including TensorRT engine dispatch on GPU builds. It is the strongest available liveness signal because it catches the silent-failure mode where /health returned 200 ok while every real embedding request returned 500 due to a broken TRT CUDA context.

§Response codes

CodeCondition
200 okServer is ready and the canary embed succeeded
503 loadingServer is still loading models
503 failCanary embed failed or timed out

§ECS and ALB configuration

Point both ECS healthCheck.command and the ALB target-group health check at /health/deep. The 30-second inference timeout ensures the health check never hangs indefinitely; keep the ECS healthCheckGracePeriodSeconds large enough to cover TRT cold-start (≥ 10 800 s for a full 24-shape grid).