Situation
We were spinning up a new pod for every run
Creating a new Kubernetes Job for every run means starting from pod startup. Every time a user sent a chat message, they had to wait before the agent started moving.
Decision 1
Separate scheduling from execution
I changed the structure so slots are filled in advance, independent of runs, and an incoming run is assigned to a ready slot. When an assignment takes a slot, the reconciler refills it.
Why
If deciding what to run and actually running it are tied together, every run has to wait until the execution environment is ready.
Decision 2
Send only interactive sessions to the warm pool
Interactive sessions go to the warm pool; one-off jobs are handled as per-run Jobs, as before.
Why
In a conversation the next input comes soon, so keeping a warm pod is worth the cost. Jobs with no next input are not.
Decision 3
Cut idle time to 60 seconds for alert jobs
A slot releases its lease when a turn ends, but the pod stays bound to that run for the idle TTL (600 seconds by default). For alert jobs that arrive automatically, there is no guarantee another input will come, yet each pod was held for 10 minutes, and just a few alerts per minute could fill the pool on their own. So I added an idle TTL to the job profile and set it to 60 seconds for alert triage jobs only.
Why 60 seconds and not 0
It costs less for the same pod to receive alerts that arrive in quick succession and a quick resolution (resolved).
Result
Measurement conditions
An observational comparison on staging, matched for model and job type. Dates and request content were not controlled, and this is latency until the run starts, not total response time.
Takeaway
The goal of starting runs faster was the same, but the cost structure differed with each workload's input pattern. Instead of applying one policy to every job, I split the design where the constraints differed.