is livekit agent statefull or stateless ? and is i...
# ask-ai
s
is livekit agent statefull or stateless ? and is it better to scale up by one pod or multi pods?
t
Thanks for reaching out, Mostafa. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether LiveKit agents are stateful or stateless, and whether to scale by increasing a single pod or using multiple pods. LiveKit agents are stateful — they maintain session-specific state for the lifetime of a conversation (audio processing, turn/context state, tool-call context, etc.). For production scaling, scale out with multiple pods (horizontal scaling). Multiple pods provide better fault tolerance, load distribution, and elastic capacity: LiveKit distributes agent sessions across worker instances and can provision additional instances as load grows. Rolling updates/draining also let you update pods without dropping active sessions. If you'd like, tell me your expected concurrent sessions, average session length, and CPU/memory used per session and I can suggest a starting pod size and replica count. Sources: An open source stack for real-time multimodal AI | Deploy and scale agents on LiveKit Cloud
s
200 sessions concurrent average 30 minutes per ssion
t
Thanks — you're asking about sizing for 200 concurrent sessions (avg 30 min). I'll respond about agent statefulness and concrete scaling guidance. LiveKit agents are stateful — each active session requires its own agent instance and holds session-specific state for the session lifetime. Recommended scaling • Provision one agent instance per concurrent session, so plan capacity for 200 agent instances at peak. • Scale horizontally (multiple pods) rather than trying to put many agents in a single pod. Horizontal scaling improves fault tolerance, rolling updates, and load distribution. • Example options: ◦ Self-managed: run multiple pods where each pod hosts a modest number of agents (for example, 10–50 agents per pod depending on node size). For 200 agents you could run 4–20 pods based on node resources. ◦ LiveKit Cloud: use its elastic scaling so instances are provisioned and drained automatically. Practical considerations • Estimate CPU/GPU and memory per agent from your workload (audio-only uses less than video/ML-heavy inference). Use that to size nodes and set pod resource requests/limits. • Use autoscaling policies (HPA/Cluster Autoscaler) and pod draining to preserve active sessions during updates. • Monitor latency, CPU/GPU utilization, and error rates; adjust pod sizes/replica counts accordingly. • Consider external storage (Redis/DB) if you need durable session persistence beyond the agent process. Would you like a suggested starting node/pod sizing if I assume light audio-only agents vs heavy GPU-based inference? Sources: Building the all-in-one platform for voice AI agents | Deploy and scale agents on LiveKit Cloud | examples/drive-thru | livekit/livekit_composite | DeepWiki
s
audio only, and suggest the starting node/pod size
t
You're asking for recommended starting node/pod sizing for 200 concurrent audio-only sessions (avg 30 min). LiveKit agents are stateful, and for audio-only workloads the recommended starting configuration is: • Node/pod size (baseline): 4 vCPU, 8 GB RAM per agent server. • Concurrency per agent server: expect ~10–25 concurrent sessions per server depending on workload and tuning. • Pods needed for 200 concurrent sessions: 8–20 pods. A practical starting point is 10 pods, each sized 4 vCPU / 8 GB, which targets ~20 sessions per pod. • Deploy horizontally and use autoscaling (HPA/Cluster Autoscaler or LiveKit Cloud elastic scaling). Monitor CPU, memory, and latency and adjust pod count or pod size as needed. Would you like a concrete Kubernetes pod spec and HPA suggestion for the 4 vCPU / 8 GB pods? Sources: An open source stack for real-time multimodal AI | Deploy and scale agents on LiveKit Cloud | Agents Framework | livekit/livekit_composite | DeepWiki | Deploying to custom environments | LiveKit docs
s
what is the requerment for the recording pods, the egress i think, for saving the composit tracks
t
You're asking about requirements for recording (Egress) pods—especially egress/egress bandwidth—for saving composite tracks. Here's a concise checklist and guidance. Resource sizing • CPU / RAM per Egress pod: 4 CPU, 4 GB RAM minimum. Composite jobs can use 2–6 CPU cores depending on resolution/layout complexity. • Pod capacity: one Room Composite job per pod (composite rendering + encoding is resource‑intensive). Media stack & container requirements • Composite rendering uses headless Chrome + GStreamer inside the pod. • Chrome sandboxing requires containers run with
--cap-add=SYS_ADMIN
or a custom seccomp profile. Storage & egress • Egress pods do not need local persistent storage for long-term retention; output must be uploaded to external storage (S3/GCS/Azure Blob). • Plan network egress bandwidth to match encoded output bitrate × concurrent recordings. For example, a single 720p composite at ~1.5–3 Mbps means ~1.5–3 Mbps × concurrent jobs. Scale network accordingly and ensure low-loss uplink to object storage or streaming targets (RTMP/HLS). Scaling & availability • Scale horizontally: run one Egress pod per concurrent composite recording. For N concurrent composites, run N replicas or use autoscaling. • Use Prometheus metric
livekit_egress_available
for autoscaling decisions; keep headroom (e.g., ~30% available) to avoid queuing. • Enable pod draining/rolling updates so in-progress composites finish or are migrated gracefully. Practical recommendations • Start with 4 CPU / 4 GB pods and size for one job per pod; increase to 6+ CPU if you need higher-res (1080p+) or complex layouts. • Test with sample layouts and target codecs to measure actual CPU, memory, and egress bandwidth before finalizing replica counts. • Configure uploads directly to S3/GCS/Azure to avoid holding large files on the pod. If you tell me expected concurrent composite recordings, target resolution/bitrate, and whether you’ll write to S3 or stream via RTMP/HLS, I can give a concrete pod count, bandwidth estimate, and an example Kubernetes deployment snippet. Would you like that? Sources: Self-hosting the Egress Service | LiveKit docs | Universal Egress | Universal Egress | Quotas and limits | LiveKit docs