egress
egress copied to clipboard
Support regional egress selection
Since LiveKit servers can run in a multi-region cluster configuration, it is pretty important that egress selection also be able to take region into account. This would be especially important on many cloud providers that have cheaper/free traffic when communicating between servers within the same region.
I think the same distanceBetween logic from the livekit server region selection should work great for this.
Hey @bekriebel, this is now possible with some slight modifications to the livekit-server code.
To achieve this, you could pass the region to the EgressService, and change
return s.StartEgressWithClusterId(ctx, "", req)
to return s.StartEgressWithClusterId(ctx, s.region, req)
here.
Then, you could set ClusterID in egress config to the region name here.
PSRPC would also need to be enabled in your livekit config:
egress:
use_psrpc: true
If you don't want the regions to be 1:1 you would need something more complex, but this would be a pretty quick way to get this working