green-parrot-24267
11/03/2025, 3:59 AMtall-airline-16756
11/03/2025, 3:59 AMtall-airline-16756
11/03/2025, 4:00 AMload_threshold, it stops taking on new jobs, which can cause the distribution to feel uneven.
• Dynamic Idle Process Adjustment: The num_idle_processes adjusts dynamically depending on the worker’s current load. So, workers with lighter loads might keep more idle processes ready and end up receiving more jobs.
• Per-Worker Load Calculation: Load is calculated individually for each worker, not across the whole cluster. This means some pods might be underused while others are busier.
• Job Distribution Mechanism: Jobs get assigned in a round-robin style, but if some workers respond slower because of high load or latency, they might get fewer jobs.
• Autoscaling Misalignment: If your Kubernetes autoscaling metrics don’t quite match the worker’s load function, the scaling might not balance the workload as well as you’d like.
To help smooth things out, I’d suggest aligning your Kubernetes autoscaling metrics with the worker’s load function and thresholds. Also, keeping an eye on CPU usage and how long processes take to start can help you spot where bottlenecks might be.
Sources: Worker options | LiveKit Docs | livekit-agents/livekit/agents/ipc/proc_pool.py | Deploying to custom environments | LiveKit Docsgreen-parrot-24267
11/03/2025, 4:07 AMtall-airline-16756
11/03/2025, 4:07 AMload_fnc to calculate load based on what matters most for your workload, like memory usage or how many jobs are running concurrently. For instance, setting a limit on the number of concurrent jobs per worker can make a big difference.
• Adjust Load Threshold: Try lowering the load_threshold (say, to 0.6) so workers start shedding load a bit earlier. This can help your system respond better and balance jobs more evenly.
• Monitor Worker Metrics: Keeping an eye on CPU usage, memory, and job throughput regularly can really help you spot any bottlenecks and fine-tune your setup.
• Graceful Shutdown: Setting terminationGracePeriodSeconds in your Kubernetes pod spec lets in-progress jobs finish during updates, which helps avoid uneven load distribution.
Making these tweaks should help your job distribution feel smoother and more balanced across your workers, all without needing to scale up automatically. If you have any questions or want to dive deeper into any step, I’m here to help!
Sources: pkg/service/agentservice.go | Worker options | LiveKit Docs | livekit-agents/livekit/agents/worker.py | Deploying to custom environments | LiveKit Docs