I want to understand how scaling works when runnin...
# ask-ai
j
I want to understand how scaling works when running an agent with LiveKit server. Please explain clearly and practically: 1. How LiveKit decides the number of workers/instances an agent uses based on system resources (CPU, RAM, storage). 2. If I provide a machine with 64GB RAM and 500GB storage, how many workers will the agent create by default, and how is this number calculated? 3. How requests are distributed across workers and what happens under high load (e.g., 1000+ concurrent users). 4. What configuration settings allow me to manually adjust scaling (e.g., max workers, concurrency per worker, autoscaling policies). 5. Best practices for balancing cost vs performance when scaling LiveKit agents.
t
Thanks for reaching out, zaeem.zahid. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
LiveKit is here to help you scale your agents smoothly, taking care of resource allocation, load distribution, and performance optimization so you don’t have to worry: Worker/Instance Allocation and System Resources Our agent workers automatically scale, with LiveKit smartly balancing the load across available workers. For a quick guide, 30 voice agents on a 4-Core, 8GB machine typically use about 3.8 CPU cores and 2.8GB of memory. To keep things running smoothly, especially during traffic spikes, we recommend allocating 4 cores for every 25 voice agents. Request Distribution and High Load Handling LiveKit uses stateful load balancing to keep agents connected to the same server, distributing jobs in a round-robin fashion. When demand is high, LiveKit Cloud automatically spins up new instances and directs traffic efficiently. Plus, geographic affinity helps reduce latency by connecting users to nearby workers. Manual Scaling Configurations If you’re working with custom deployments, you can tweak the
load_fnc
(load function) and
load_threshold
in WorkerOptions to fit your scaling needs. By default, we monitor CPU utilization with a 70% threshold. Just a heads-up: on LiveKit Cloud, custom settings aren’t supported to keep performance consistent for everyone. Cost-Performance Best Practices To strike the right balance between cost and performance, stick with 4 cores per 25 voice agents. Overloading machines can impact audio/video quality, which we definitely want to avoid. Our pricing is straightforward—$0.01 per agent session minute, covering global hosting, unlimited data transfer, and observability features. For production environments, it’s best to separate projects for development and allow enough grace periods during rollouts for a smooth experience. If you have any questions or need help customizing your setup, please don’t hesitate to reach out. I’m here to support you every step of the way! Sources: Deployment and scaling | LiveKit Docs | Deploying to custom environments | LiveKit Docs | Deploy and scale agents on LiveKit Cloud | An open source stack for real-time multimodal AI | agents/src/worker.ts
j
tell me how much ram or storage a single worker take in livekit
t
Thanks for reaching out! The resource usage of a single LiveKit worker really depends on the workload and the plugins you’re using. Let me share some general guidelines to help you plan: Storage: Workers need very little persistent storage. We usually recommend setting aside 10GB of ephemeral storage to cover the Docker image (which is under 1GB) and any temporary runtime files. RAM: For most voice AI applications, it’s a good idea to allocate 8GB of RAM per worker. For example, in a load test with 30 voice agents, a 4-core, 8GB machine used about 2.8GB of memory. Keep in mind, plugins like the Turn Detector might use a bit more memory, around ~200MB for the English model. CPU: We suggest 4 CPU cores per worker. In that same load test, CPU usage went up to about ~3.8 cores for 30 agents. If you’d like, I’m here to help with any more details or to assist you in planning your resources. Just let me know! Sources: agents/src/worker.ts | Deploying to custom environments | LiveKit Docs | Docs::Agents | Deployment and scaling | LiveKit Docs | livekit-agents/livekit/agents/worker.py
j
If I provide a machine with 64GB RAM and 500GB storage, how many workers will the agent create by default, and how is this number calculated?
t
Thanks for reaching out! To help you better, could you please let me know if you're using LiveKit Cloud or a self-hosted deployment? The way we check the number of workers can be a bit different depending on which setup you have. I'm here to guide you through it!
j
self-hosted
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!