millions-eye-11809
07/14/2025, 1:38 PMtall-airline-16756
07/14/2025, 1:38 PMtall-airline-16756
07/14/2025, 1:39 PMload_fnc
(which typically measures CPU or custom resource usage) exceeds this value, the worker is marked as unavailable for job assignments.
• Default values: In production, defaults are 0.75 (Python) or 0.65 (JavaScript). In development, it is effectively disabled (infinity).
• When the worker load exceeds load_threshold
, the worker's status changes so it's no longer routed new jobs, supporting stable load balancing and resource protection.
• You can pair load_threshold
with a custom load_fnc
to use metrics beyond CPU, such as running job count.
• In production, set your autoscaling triggers lower than the load_threshold
to ensure new workers are provisioned before existing ones reach their limit.
This parameter is essential for balanced distribution and high availability in scaled deployments.
For implementation details and practical configuration examples, refer to the sources for full context.
• Python and JS worker behavior: see
• Production scaling guidance: see Sources: Deploying to production | LiveKit Docs | WorkerOptions | LiveKit Agents | Worker options | LiveKit Docs | livekit-agents/livekit/agents/worker.py | agents/src/worker.tsmillions-eye-11809
07/14/2025, 1:40 PMload_fnc
?tall-airline-16756
07/14/2025, 1:41 PM_DefaultLoadCalc
class in livekit-agents/livekit/agents/worker.py
(lines 81–108). It's pretty neat how they calculate things!
• Node.js workers: Their magic happens in the defaultCpuLoad
function within agents/src/worker.ts
(lines 79–111).
Here's the cool part: both approaches look at CPU utilization. They're basically checking how hard your computer is working, using smart methods to track CPU percentage and return a value between 0 and 1. Think of it like a stress meter for your machine! 💻
This helps determine when a worker should take a break from accepting new jobs, based on the load_threshold
.
• Source details on function location and logic:
• Default metric and value range: Sources: agents/src/worker.ts | Worker options | LiveKit Docs | Deployment and scaling | LiveKit Docs | livekit-agents/livekit/agents/worker.py