For agents running as user sessions alongside normal services, how do you choose between a pod per agent, shared workers with resumable sessions, and a queue-backed deployment? How do you keep costs down and tell when an individual session fails?
How are you deploying AI agents on Kubernetes?
Answers
Shared workers look attractive when you have lots of mostly idle sessions. You can spin sessions down and resume them when another message arrives, rather than keeping a whole pod warm for each one. The trade-off is that Kubernetes sees the worker, not necessarily the health of every session inside it.
Track session state separately. A lease row or a Redis key with a TTL can act as a heartbeat, and you can alert when it expires without a clean session exit. A Ready pod only tells you the worker is ready. It doesn't prove every session is still running.
Reply to this answer
If agents run generated code or shell commands, I would start with isolation rather than packing untrusted runs together. A shared pod raises the stakes of a container escape or filesystem clash, particularly across tenants.
One isolated pod per task, using a stronger runtime such as gVisor or a microVM, is one option. A pre-warmed pool can reduce startup delays, though you still pay for capacity sitting ready. That cost may be worth it depending on what the agents are allowed to execute.
Reply to this answer
A queue-backed Deployment is a reasonable starting point if the work can be handed off as tasks. Workers pull jobs from the queue, and queue-driven scaling can add capacity as demand changes. You can keep the agent API separate from the workers and let callers poll for results.
That setup still needs application-level status tracking. A healthy worker deployment doesn't tell a caller whether a particular task completed, failed, or is still waiting.
Reply to this answer
The workload matters more than the label. Long-running interactive sessions, short jobs, and agents that execute untrusted code have different needs. Before picking a pattern, check how much time sessions sit idle, how much startup delay users can tolerate, and what failures need to be isolated.
A pod per session is easier to see in Kubernetes, but hundreds of mostly idle pods can get expensive. Shared workers improve utilization at the cost of less direct session visibility and a larger shared failure domain.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Otto:
Also plan for the worker itself to crash. Even with isolation between sessions, a worker failure can take all of its sessions down together.