Sub topic 9
Choosing What to Scale On
Prerequisites: You should understand model-serving endpoints, p50 and p99 latency, basic Kubernetes Deployments, and the difference between a request queue and an in-flight request.
Horizontal autoscaling adds or removes model replicas. A replica is one running copy of the model server. The autoscaler needs a signal that shows when existing replicas cannot meet demand. The best signal is usually close to the user-visible problem, such as queue growth or excessive latency.
Queue depth
Queue depth is the number of requests waiting for a model server to process them. It directly measures unmet work.
A growing queue usually means that requests arrive faster than replicas can finish them. This makes queue depth a useful signal for dynamic batching. The batcher can still collect requests, but a sustained queue indicates that batching alone is no longer enough.
Queue depth has two limitations:
- A queue can be empty while replicas are fully occupied if requests are being processed immediately.
- A single large request may consume more work than many small requests, even though both count as one item.
Use queue depth when requests have similar costs and the serving system exposes a reliable metric.
Concurrency
Concurrency is the number of requests currently being processed. It shows how much serving capacity is in use.
For example, if each replica safely handles eight concurrent requests and every replica is processing eight requests, the service has reached its practical limit. Concurrency is often more useful than CPU utilization for GPU-backed inference because the GPU may appear underused while the model server is blocked on another resource.
Track concurrency per replica or normalize it by replica count. A total concurrency value can rise simply because the autoscaler added replicas, so it needs careful interpretation.
Resource utilization
Resource utilization includes CPU, GPU, memory, and other infrastructure measurements. It is easy to collect and works well when resource use closely follows inference work.
Utilization alone can mislead:
- High CPU may come from tokenization or networking rather than model execution.
- Low GPU utilization may result from small batches, synchronization delays, or memory limits.
- High memory usage does not necessarily mean that requests are waiting.
- A short utilization spike may disappear before a new replica becomes ready.
Use utilization as a supporting signal or when it has a demonstrated relationship with latency and queueing.
| Signal | Best indication | Common failure |
|---|---|---|
| Queue depth | Work waiting for service | Misses work already in progress |
| Concurrency | Active capacity consumption | Needs a safe concurrency limit |
| GPU or CPU utilization | Resource pressure | May not match user latency |
| p99 latency | User-visible performance | Reacts after the problem begins |
Combine signals with service objectives
A service-level objective (SLO) is a target such as “99% of requests finish within 300 milliseconds.” Compare each signal with latency measurements. If queue depth rises before p99 latency violates the SLO, queue depth can provide useful early scaling.
Avoid scaling directly on raw p99 latency unless the metric is stable and the policy has enough delay protection. Tail latency can fluctuate because of a few slow requests, causing replicas to flap.
A practical selection process
- Measure queue depth, concurrency, resource utilization, and p99 latency together.
- Create controlled load increases and record which metrics move first.
- Select an early signal for scale-up, often queue depth or concurrency.
- Select a slower, stable signal for scale-down.
- Set limits so scaling cannot exceed available GPU capacity or create excessive cost.
- Recheck the relationship after changing batch size or model version.
Exercise
A service has low GPU utilization, rising queue depth, and worsening p99 latency. Which signal should trigger scale-up first, and why?
Show answer
Use queue depth, possibly combined with concurrency. The queue proves that requests are waiting, while low GPU utilization may indicate small batches or another bottleneck rather than spare serving capacity.