You're asking what happens if you run both the LiveKit server and your worker agents on the same 4 vCPU / 8 GB EC2 instance. Short answer: it works initially, but it creates strong risks for performance, reliability, and scaling — the agents are likely to become the bottleneck and can disrupt real‑time media.
Key impacts
• Resource contention: LiveKit (SFU) and agents compete for the same CPU, RAM, and network. Real‑time media forwarding is sensitive to CPU and network jitter, so contention causes audio latency, packet drops, and choppy audio.
• CPU throttling risk: If you use burstable instance types (t3/t4g), sustained agent spikes can exhaust CPU credits and throttle the whole host, which will degrade LiveKit’s realtime performance.
• Unpredictable latency: Heavy agent tasks (STT/TTS/LLM inference) cause CPU and scheduling spikes that increase packet processing latency for WebRTC.
• Reliability coupling: A crash, high memory use, or heavy GC on the agent process can destabilize or force restarts of the LiveKit process on the same host, interrupting all sessions.
• Scaling limitations: You can’t independently scale LiveKit vs agent capacity. Paying to scale one component forces scaling the other, increasing inefficiency and cost.
When this setup might be acceptable
• Small test/dev deployments with very low concurrent sessions and lightweight agent work.
• Short experiments before you implement horizontal scaling or separate hosts.
Recommended approach
• Separate LiveKit server and agent workers onto different instances or node pools.
• Scale agents horizontally (multiple worker instances) behind a dispatcher/load balancer.
• Offload heavy inference to cloud APIs or dedicated GPU instances if needed.
• Use fixed CPU instance families (c5/m5) rather than burstable types for production LiveKit hosts.
• Monitor Prometheus metrics (LiveKit) and host CPU/memory on agents and autoscale agents based on CPU or queue backlog.
If you want, I can:
• Suggest a concrete separation and sizing plan for your current ~30-session target, or
• Outline a simple load test to measure how much contention you observe when co‑located. Which would you prefer? Sources:
Deploying to custom environments | LiveKit Docs |
Troubleshooting Latency and Timeout Errors with Turn Detection on AWS |
Deploy and scale agents on LiveKit Cloud |
Deploying to production | LiveKit Docs