r/devops • • 10d ago

Discussion If your gpu inference pods scale to zero, what actually wakes them back up?

Been reading abt KEDA scale-to-zero for llm inference

Turning off idle gpu pods make sense, but what happen when an ai agent needs the model again?🤔

If u r scaling base on vllm metrics, those metrics disappear once all the pods r gone. So something else has to catch the request n wake them up again.

KEDA’s HTTP interceptor can hold request while the backend starts, but u r still waiting on gpu provisionong n model loading

N what if the agent time out n retries before the model is ready?

For people running this in production, r u keeping one warm replica or just queueing request until the gpu is ready? Especially for agent making multiple llms call between tool runs

12 Upvotes

19 comments sorted by

12

u/Feisty-Piglet7758 10d ago

The signal you scale on has to exist while zero pods exist, so scale on the work, not on vLLM: Redis or Kafka queue depth, or the interceptor's pending count. Then use one number to decide. Cold GPU node plus weights is 3 to 10 minutes, a warm node with the model on local NVMe is 30 to 90 seconds, and an agent that times out at 30 cannot survive either. Interactive traffic gets minReplicas 1 and scale to zero belongs to batch, and bake the weights into the image or a node cache, because a 40 GB pull is usually the biggest part of that cold start.

1

u/Chamelon_DE 5d ago

The external queue metric make sense. I’m curious abt the warm node part though, would u still keep one model relica loaded for interactive agent or rely on local nvme caching?

1

u/ozankurt_dev 9d ago

startupProbe covers model loading?

1

u/[deleted] 9d ago

[removed] — view removed comment

1

u/ozankurt_dev 9d ago

gpu scheduling, fair point, i'd keep one replica warm.

4

u/Starks1293 10d ago

adding to the queue depth answer, the agent side matters as much as the scaler

  • the timeout and retry bit is the real trap. if the agent retries a held request u end up with 3 copies queued for a model thats still loading. give the client one long timeout for the first call (longer than ur worst cold start) or return a 202 with a job id and let it poll, and make retries carry the same request id so the backend can drop duplicates
  • agents make bursts of calls with gaps while tools run, so a short cooldown makes the model flap. set the KEDA cooldownPeriod longer than the longest tool gap, like 10 to 15 min, so it stays warm for the whole task and only sleeps when the agent is really done
  • most of the cold start is the node and the weights, not the pod. keeping one cheap gpu node up with zero pods, or weights on a local disk or a pre pulled image, cuts minutes to seconds
  • if nobody can wait at all, one warm replica during working hours and scale to zero at night with a cron scaler is the boring answer that usually wins

1

u/Chamelon_DE 5d ago

The duplocate request issue is a gud point. Wondering if using the same request ID across retries is enough, or if you’d also neef some kind of deduplication state at the gateway?

1

u/Starks1293 5d ago

the id alone isnt enough, something has to remember it. and it has to be shared state, not memory in one pod, because when u scale from zero the retry can land on a different replica than the first try

what works is a small store keyed by request id, redis with SET NX and a ttl is plenty. first request writes in-flight and goes through. a retry with the same id sees in-flight and waits on that one instead of starting a second generation, or gets a 202 with the same job id back. when it finishes u keep the response under the id for the ttl, so a late retry just gets the stored answer. set the ttl longer than the clients whole retry window, a few minutes is usually fine for inference

put it at the gateway if u have one in front of several backends, thats the one place every retry passes through. the keda interceptor holds requests while the pods come up but doesnt dedupe, so it doesnt replace this

and the cheapest fix is still on the client. a first call timeout longer than ur worst cold start means most of those retries never happen

21

u/redvelvet92 10d ago

System of a Down song yelling, WAKE UP bahahahahahaha make up!

4

u/HousingInner9122 9d ago

I'd keep one warm replica for agent workloads, since waiting for GPU provisioning and model loading on every cold start sounds like a nightmare for timeouts and retries.

1

u/hw999 10d ago

Keda keeps a controller pod running when in scale.to zero mode. Its best to have it run on some.cheap CPU nodes.

1

u/alluran 9d ago

You trying to save tokens or something?

1

u/Hostman_com 9d ago

Measure from the agent's first request to the first token after scaling to zero. Test with the GPU node still running, then with the node gone too.

Track node provisioning and model loading separately. Compare both end-to-end times with the agent's timeout before deciding whether a warm node is enough or you need to keep the model loaded.

1

u/Training-Hope-7232 7d ago

Keeping a small warm pool seems like a good middle ground, especially when cold starts and model loading can make agent timeouts pretty unpredictable.