Skip to content

Add load_distribution strategy (consolidate | spread)#1248

Open
chalapathi444 wants to merge 1 commit into
livekit:mainfrom
chalapathi444:feat/load-distribution
Open

Add load_distribution strategy (consolidate | spread)#1248
chalapathi444 wants to merge 1 commit into
livekit:mainfrom
chalapathi444:feat/load-distribution

Conversation

@chalapathi444

Copy link
Copy Markdown

What

Adds a load_distribution service config that controls how StartEgressAffinity routes jobs across server instances.

Why

The current affinity scorer always consolidates: idle servers return a lower score so jobs pack onto already-busy instances, keeping idle servers free for heavier egress types (room composite, web). That is ideal for mixed deployments, but for track-only fleets it concentrates load and leaves headroom stranded.

How

load_distribution: consolidate  # default
# or
load_distribution: spread
  • consolidate (default): unchanged behavior — packs jobs onto busy servers.
  • spread: returns a new Monitor.AvailableCPURatio() as the affinity score, so the server with the most available CPU wins each selection round and load is distributed evenly.

AvailableCPURatio() reuses the existing getCPUUsageLocked() accounting and is clamped to [0, 1]. Defaults to consolidate when unset, so existing deployments are unaffected.

Notes

  • gofmt clean. Verified compilation and interface satisfaction locally; I couldn't run the GStreamer-dependent integration suite in my environment, so a CI run is appreciated.
  • I kept this independent of any kill/graceful-stop changes so it can be reviewed and merged on its own.

Adds a `load_distribution` service config that controls how the affinity
scorer routes egress jobs across server instances:

- "consolidate" (default, unchanged behavior): packs jobs onto already
  busy servers, keeping idle servers free for heavier egress types
  (room composite, web).
- "spread": routes each job to the server with the most available CPU,
  distributing load evenly. Recommended for track-only deployments.

The spread strategy uses a new Monitor.AvailableCPURatio() as the
affinity score, so the server with the most headroom wins each
selection round. Defaults to "consolidate" when unset.
@chalapathi444 chalapathi444 requested a review from a team as a code owner June 6, 2026 06:50
@CLAassistant

CLAassistant commented Jun 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants