This article highlights a critical gap in deploying Large Language Models (LLMs) on Kubernetes: while Kubernetes might report a pod as 'Ready', the underlying LLM may not yet be capable of performing inference. It details experiments measuring the 'Ready-to-inference' gap and proposes a more robust readiness probe that actively verifies model loading and inference capability, crucial for reliable LLM serving.
Read original on DZone MicroservicesDeploying Large Language Models (LLMs) in Kubernetes presents unique challenges beyond traditional microservices. A common pitfall is relying solely on basic HTTP readiness probes, which can signal a pod as healthy even if the LLM within it is not fully loaded or ready to serve inference requests. This discrepancy can lead to service degradation, increased latency for initial requests, and an unreliable user experience, especially during deployments or scaling events.
The article demonstrates through experiments that there's a significant time gap between when Kubernetes reports an LLM serving pod as 'Ready' (T1) and when it can successfully complete its first inference request (T4). This 'Ready -> inference gap' can range from several seconds to over ten seconds, depending on the model size and environment. This gap arises because 'Ready' typically only confirms the process is running and an API endpoint is reachable, not that the model is loaded into memory and prepared for computation.
To accurately determine LLM readiness, the probe must verify that the model is not only present but also fully loaded and capable of serving requests. The proposed solution involves an `exec` probe that performs a minimal inference request against the LLM's API. This ensures the entire inference pipeline, including model loading and actual computation, is functional before the pod is considered 'Ready' by Kubernetes.
readinessProbe:
exec:
command:
- sh
- -c
- |
curl -sf -X POST http://localhost:11434/api/generate \
-H 'Content-Type: application/json' \
-d '{"model":"llama3.2:1b","prompt":"ping","stream":false}' \
| grep -q '"done":true'
periodSeconds: 2
failureThreshold: 1Key Takeaway: Readiness is a Contract
This stronger readiness contract ensures that new pods in a deployment rollout do not receive traffic until they are truly ready to infer, preventing service interruptions and performance spikes during scaling or updates. It shifts the definition of 'Ready' from mere process health to actual application functionality for LLMs.