App
Starting a model server
Big images, slow loads, startup probes
A model server is an ordinary Deployment with unusual numbers. vLLM serves Llama 3.1 8B on node-2's L4: its image is about 9 GB, the model's weights are 16 GB more, and both have to arrive before the weights are loaded into the GPU's memory. That takes minutes, and a liveness probe written for a web app kills the server before it ever answers. Follow the first start, the restarts that never finish, and the startup probe that fixes it.
- Server
- vLLM · OpenAI-compatible API on :8000
- Model
- Llama 3.1 8B Instruct · BF16 · 16 GB
- GPU
- NVIDIA L4 · 24 GB · on node-2
- First start
- ≈ 7 min of pull, download and load
Read the whole lesson as text
1. The spec
You apply a Deployment llm running vllm serve with Llama 3.1 8B. It asks for nvidia.com/gpu: 1 and tolerates node-2's GPU taint, as in A Pod asks for a GPU. A Secret holds the Hugging Face token the model needs. A PersistentVolumeClaim is mounted at /root/.cache/huggingface for the weights. The strategy is Recreate: with one GPU, a new Pod can't start until the old one lets go of it. And there's a liveness probe on /health, copied from a web app: 30 seconds' delay, three failures.
- You create the llm Deployment: vLLM, one GPU, a weights cache and a liveness probe.
- Only node-2 has a GPU, so the scheduler binds the Pod there.
2. A huge pull
Inside node-2, the kubelet allocates the GPU and asks containerd for the image. node-2 has never run vLLM, so containerd downloads every layer: CUDA libraries, PyTorch, vLLM itself, about 9 GB compressed. At 60 MB/s that's two and a half minutes, and unpacking the layers adds another. The probes haven't started; the container doesn't exist yet. On a node that already has the image, this step takes seconds, as in Image pull.
- The GPU is allocated. The kubelet asks containerd for the vLLM image.
- containerd downloads the image's layers: about 9 GB.
- Downloaded and unpacked, 3 minutes 30 seconds later.
3. Killed while loading
vLLM starts and begins downloading 16 GB of weights from Hugging Face. Its HTTP server doesn't exist yet: vLLM starts it only once the model is loaded. Thirty seconds in, the kubelet's liveness probe gets connection refused, then twice more, ten seconds apart. Three failures: the kubelet kills the container and starts it again. The new one starts the same long load, and is killed at the same point. After a few rounds the Pod shows CrashLoopBackOff and the waits between restarts grow.
- vLLM starts and begins downloading the model's weights into its cache directory.
- Thirty seconds after the start, the liveness probe finds nothing listening on :8000.
- The third failure in a row: the kubelet kills vLLM and starts the container again.
- The same thing, every time. The kubelet waits longer before each restart.
4. The startup probe
The fix is a startup probe. While a container has one that hasn't succeeded yet, the kubelet doesn't run its liveness or readiness probes at all. This one checks /health every 10 seconds and allows 60 failures, so vLLM has up to 10 minutes to start. Once it succeeds, the liveness probe takes over and can be as strict as before. You change the Deployment; Recreate deletes the crashing Pod, which frees the GPU, and the new Pod starts on node-2 with the image already there.
- You add a startup probe and a readiness probe to the Deployment.
- Recreate scales the old ReplicaSet to zero first, which frees the GPU, then creates the new Pod.
5. Weights
The new container starts in seconds, since node-2 already has the image. vLLM finds the weights partly downloaded on the PVC and fetches the rest from Hugging Face. Meanwhile the startup probe fails quietly every 10 seconds, and nothing kills the container. The download is the step a cache changes most: from now on the weights are on the PVC, and any later start reads 16 GB from disk instead of the internet.
- vLLM resumes the download where the last attempt stopped.
- The startup probe fails, as expected. Unlike the liveness probe, it has 60 tries.
- All four files are on the PVC. Every later start can skip the internet.
6. Into VRAM
vLLM loads the 16 GB of weights into the L4's memory. Then it measures what's left and reserves most of it for the KV cache, which holds the attention state of every request in progress: its --gpu-memory-utilization flag says what fraction of the card it may use in all. It captures CUDA graphs for common batch sizes, so later steps launch faster. Only then does its HTTP server start. The next startup probe gets 200, readiness passes, and the Pod joins the Service's endpoints.
- vLLM copies the weights from the PVC into the GPU's memory.
- It reserves the KV cache from what's left and captures CUDA graphs.
- The HTTP server is up. The startup probe gets 200, and the readiness probe starts.
- Readiness passes. The Pod is Ready and the Service starts sending it requests.
7. Where the time goes
Add up a cold start on a fresh GPU node: the node itself, a minute or more if an autoscaler has to make it, as in A node joins the cluster; three and a half minutes of image pull; nearly three minutes of weights; and about a minute to load and prepare. Each part has a fix. Pre-pull the image on GPU nodes. Keep the weights on a volume or in object storage near the cluster. Keep one replica warm. Scaling a model server to zero, as in Scale to zero with KEDA, means the first request after a quiet spell pays the rest.
- An hour later the Pod restarts. Image and weights are on node-2 now, so it's Ready in about a minute and a half.
Summary
A model server is slow to start for honest reasons: a big image, bigger weights, and a load into GPU memory, in that order, before its HTTP server exists. A liveness probe can't tell slow from stuck, so it kills a server that was making progress. A startup probe gives the start its own budget and holds the other probes back until it's over. Then each part of the wait has its own fix: pre-pulled images, cached weights, a warm replica.
Next lesson: ConfigMaps and Secrets