Free How much of your firm runs on you? Take the 2-minute Key Man Score.
Lesson reading
0%

Lesson 19 / Unit 5: Capacity Planning

Port Capacity

Audit a saved port counter, compare range mode with UDP multiplexing, and measure the actual transport limit before choosing a node capacity.

A saved load report listed 11,120 “media ports” at 612 calls against a configured range of 10,001 ports. That is a reason to inspect the measurement, not enough evidence to declare a LiveKit capacity limit.

This lesson separates the old report from the test you need before using it to size a fleet.

Saved Measurements

These values came from the earlier course material. The raw socket capture, collection script and exact server build are not bundled here.

Calls on nodeReported port countReported CPU
2043,73835.4%
4087,42256.5%
61211,12075.7%

The count grows at roughly 18 ports per call. But “port count” could mean socket rows, local endpoints, remote endpoints or several processes combined. Those are different resources. Until the counter is identified, dividing 10,001 by 18.3 does not establish a 550-call ceiling.

Metric Identity

Count unique local UDP bindings in the relevant network namespace and configured range. Keep the owning PID, local address, port and collection time. Do not count remote peer ports as local allocations.

On Linux, inspect bindings with:

sudo ss -H -u -a -n -p

The ss manual explains the columns. Capture the output before, during and after a small known number of calls. Compare the socket changes with participant counts and the running config. Shared ports and multiple local addresses need separate interpretation.

A count above the range size cannot represent unique port numbers inside that one range. Resolve that contradiction before extrapolating.

Range and Mux

LiveKit supports both a UDP port range and UDP multiplexing. The official port reference documents both; the server sample config shows their configuration.

Transport modeConfigurationWhat to measure
UDP rangertc.port_range_start and rtc.port_range_endAllocated local ports, participants, allocation failures
UDP muxrtc.udp_portSocket traffic, packet rate, CPU, bandwidth and loss
ICE TCP / TURNSeparate fallback pathsSelected candidate pairs and relay load

Example range configuration:

rtc:
port_range_start: 50000
port_range_end: 60000

Example mux configuration, as an alternative:

rtc:
udp_port: 7882
# Do not set port_range_start or port_range_end for this mode.

Open the configured media ports in the firewall. Mux removes the same range-allocation model; it does not remove CPU, bandwidth or packet-processing limits.

Capacity Experiment

Use a controlled ramp with the same participants, subscriptions, codecs and transport paths as production.

  1. Save the server version, config and firewall rules with the run.
  2. Record active rooms, participants and unique local bindings per node.
  3. Record setup failures, packet loss and decoded audio in both directions.
  4. Hold each step long enough to distinguish startup pressure from steady load.
  5. Change one suspected limit and rerun. A larger port range should move a true range ceiling; it should not fix a CPU bottleneck.

A call can complete SIP signalling while WebRTC media fails. Inspect ICE and server errors too; “no error” is not a guaranteed symptom of allocation failure.

Safe Changes

Allow any new media range before advertising it. Drain the node before restarting it with changed transport settings, then place calls over direct and fallback paths.

Use the first verified limit, with headroom, as your operating cap. The old 400-call cap can remain a historical planning choice; it is not a recommendation for an unmeasured deployment.

Next: Autoscaling Signals combines a measured node cap with placement and drain behaviour.

Common questions

How many UDP ports does a LiveKit call use?

There is no single ports-per-call constant. Transport mode, participants and subscriptions matter. Identify distinct local allocations before interpreting a socket count.

What happens when a LiveKit node runs out of RTP ports?

Signalling may succeed while media allocation or ICE fails. Inspect media errors and per-call audio rather than relying on CPU or SIP completion alone.

Does a bigger instance fix LiveKit port exhaustion?

Extra CPU does not expand a configured port range. First prove that range allocation is the constraint; widening the range or choosing mux changes different aspects of the transport.

We do this work for teams shipping voice agents: Self-Hosted Voice Agent .

Edit this lesson on GitHub ↗

Discussion

Questions, corrections and war stories welcome. Sign in with GitHub to comment.

Free guide

Be The 10x Entrepreneur

Get the firm out of your head.

  • 8 chapters
  • 7 worksheets
  • 30 day plan