livekit / egress

Export and record WebRTC sessions and tracks
https://blog.livekit.io/livekit-universal-egress-launch/
Apache License 2.0
170 stars 71 forks source link

Support regional egress selection #22

Open bekriebel opened 2 years ago

bekriebel commented 2 years ago

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.

frostbyte73 commented 1 year ago

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