Kubernetes for Model Serving
You'll learn to
- -Describe how a pod asks for a GPU and how it is placed on a node with the right kind of GPU
- -Explain why a model server needs a readiness check that waits for the model to load
- -Say why queue depth or in-flight requests make a better scaling signal than CPU
- -Reason about load time, headroom and cost when autoscaling a GPU service
Tip: the highlighter is on - just select any text below to mark it. Use the highlighter button up top to change color or turn it off. Highlights are saved on this device only. Log in to save them to your account instead.
Kubernetes is the system many companies use to run services on a fleet of machines. You describe what you want, such as three copies of this model server, and Kubernetes places them, restarts them when they fail and replaces them during an update. Serving a model on it works much like serving any service, with three differences that matter a great deal: GPUs, slow startup and the signal you scale on.
An Analogy: A Shop Manager and a Staff Roster
A shop manager keeps a roster: this many people on the floor, a specialist at the counter that needs a license, and a rule that nobody is put on the floor until their induction is finished. If a person calls in sick, the manager brings in another. The pods are the staff, the node pools are the departments, the GPU request is the specialist's license, and the readiness check is the induction-finished rule.
GPUs, Nodes and Pods
A pod asks for a GPU by naming a special resource that a device plugin installed on the node makes available, for example nvidia.com/gpu. The Kubernetes documentation says GPUs are specified in the limits section: you may give a limit without a request, because the limit is used as the request, or give both, and they must be equal. If your cluster has different types of GPUs, label the nodes and use a node selector so the pod lands on the right one.
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {"name": "llm-server"},
"spec": {
"nodeSelector": {"accelerator": "example-gpu-x100"},
"containers": [{
"name": "server",
"image": "registry.example/llm-server:v1",
"resources": {"limits": {"nvidia.com/gpu": 1}},
"readinessProbe": {
"httpGet": {"path": "/ready", "port": 8000},
"initialDelaySeconds": 30,
"periodSeconds": 5
}
}]
}
}The readiness probe is the second difference. A model server can take a minute or more to load weights into GPU memory. Until it is ready, sending it traffic only produces errors, so the pod reports ready only after the model is loaded. The same slow start makes rolling updates harder. Replacing a pod needs a spare GPU to start the new one while the old one still serves, or else capacity dips during every deploy.
Scaling on the Right Signal
The usual autoscaler adds pods when CPU use is high. A GPU model server is different: its CPU is mostly idle while the GPU is the bottleneck, and GPU utilization stays near 100 percent whenever the server is busy, whether the backlog is ten requests or a thousand. Better signals are the queue depth, the number of requests in flight, or the time requests wait. Kubernetes can scale on custom and external metrics like these.
The simulation has traffic that jumps from 8 to 30 requests a second for 50 seconds. Each replica serves 5 a second and takes 45 seconds to load the model. The utilization policy adds one replica at a time. The demand policy sizes to the traffic it sees, targeting 70 percent busy. The last two rows keep spare replicas ready.
Adding one replica at a time, the utilization policy leaves requests waiting up to 90 seconds and misses the 10 second limit for 128 seconds. Sizing to demand helps a little, 53.3 seconds worst, because the 45 second load time means the new replicas arrive after the queue has already built up. The real fix is headroom. Starting with 4 replicas cuts the worst wait to 22.5 seconds, and starting with 6 removes the problem, but the replica-seconds, our cost proxy, rise from 471 to 670 to 978. Spare GPUs are the price of a fast reaction.
Load time is the number to attack. Smaller or quantized weights, a local cache of the model files and keeping a pool of warm replicas all shorten the gap between deciding to scale and actually serving.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!