wide-dress-57902
08/14/2025, 10:54 PMtall-airline-16756
08/14/2025, 10:54 PMtall-airline-16756
08/14/2025, 10:54 PMnum_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!wide-dress-57902
08/14/2025, 10:55 PMwide-dress-57902
08/14/2025, 10:55 PMtall-airline-16756
08/14/2025, 10:56 PMtall-airline-16756
08/14/2025, 10:56 PMwide-dress-57902
08/14/2025, 10:56 PMtall-airline-16756
08/14/2025, 10:57 PMagent_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:
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!