how many agents can one worker handle, for product...
# ask-ai
w
how many agents can one worker handle, for production purposes?
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Just so you know, in a real-world setup, a LiveKit worker can usually handle about 10-25 agents at the same time, depending on the CPU and memory of the machine. For instance, on a 4-core, 8GB machine, running 30 agents used around 3.8 cores and 2.8GB of RAM, which means roughly 4 cores for every 25 agents works well. To get the best performance, you can tweak settings like
num_idle_processes
and
load_threshold
. Also, it’s a good idea to scale out by adding more workers instead of pushing one worker too hard. This way, everything runs smoothly!
w
So for example, a 1000 concurrent users, would require many workers
?
t
Hey! For handling 1,000 concurrent users, you'll want to have multiple workers running. Typically, each worker supports between 10 to 25 agents, but the exact number really depends on your machine’s specs and setup. Just to give you an idea: • If one worker manages 25 agents, you'd be looking at around 40 workers. • If one worker manages 10 agents, then about 100 workers would do the trick. It’s a good idea to keep an eye on your resource usage and add more workers as you go, so everything runs smoothly without a hitch.
Hey there! So, for handling 1000 concurrent users, you’ll want to have multiple workers running. Typically, each worker can manage between 10 to 25 agents, depending on your machine’s specs. Here’s a quick way to think about it: • If each worker handles 25 agents, you’d need around 40 workers. • If each worker handles 10 agents, then about 100 workers would do the trick. Of course, the exact number really depends on your hardware and setup. It’s a good idea to keep an eye on your resource usage and add more workers as you go to make sure everything runs smoothly.
w
If I were to do explicit dispatch, how would it be spread across different workers, so the load is balanced?
t
Hey there! If you want to balance the load across workers using explicit dispatch in LiveKit, here’s a simple way to do it: 1. Enable Explicit Dispatch: Just set the
agent_name
in
WorkerOptions
. This turns off automatic dispatch and gives you manual control over which agents get assigned where. 2. Create Explicit Dispatches: Use the
AgentDispatchService
API to assign agents to specific rooms. Here’s a quick example:
Copy code
import asyncio
from livekit import api

room_name = "my-room"
agent_name = "test-agent"

async def create_explicit_dispatch():
    lkapi = api.LiveKitAPI()
    dispatch = await lkapi.agent_dispatch.create_dispatch(
        api.CreateAgentDispatchRequest(
            agent_name=agent_name, 
            room=room_name, 
            metadata='{"user_id": "12345"}'
        )
    )
    print("Dispatch created:", dispatch)
1. Keep an Eye on Worker Load: Set up
load_fnc
and
load_threshold
in
WorkerOptions
so a worker knows when to stop taking on new jobs based on how busy it is. 2. Use LiveKit’s Built-in Job Distribution: The system automatically assigns jobs in a round-robin style and smartly reroutes them if a worker is unavailable or overloaded. By keeping track of worker loads and using explicit dispatch, you’ll have a smooth and efficient way to balance work across your team. If you have any questions or need a hand, just let me know!