Multiple TURN servers - how to make load balancing?

2,460 views
Skip to first unread message

Jindrich Sarson

unread,
Nov 12, 2014, 5:33:23 PM11/12/14
to discuss...@googlegroups.com
Hi,

we are deploying several TURN servers in different places to cover fast connection around the world. However - in some places, one TURN server will not be enough. Could be TURN server configured to accept only specific number of connections, so that then WebRTC will use another server? Or how is possible to load balance traffic on TURN?

Thanks,

Jindrich

Philipp Hancke

unread,
Nov 12, 2014, 5:46:29 PM11/12/14
to discuss...@googlegroups.com
There are multiple ways of doing this... 
Chrome 39 is going to add support for the alternate server mechanism -- https://code.google.com/p/webrtc/issues/detail?id=1986
This would allow the turn server to redirect the client to another server if it's close to it's capacity limits.

The other approach is to give out different TURN servers to each client based on load information (bitrates, # current allocations, # of open channels) that your TURN servers send to your TURN load balancer thing.
It's somewhat more complicated because you need to estimate a load / allocation ratio, but works quite well in practice.

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kaiduan Xie

unread,
Nov 13, 2014, 9:24:08 AM11/13/14
to discuss...@googlegroups.com
You can also consider DNS round robin for load balancing.

/Kaiduan

Jindrich Sarson

unread,
Nov 14, 2014, 4:35:02 PM11/14/14
to discuss...@googlegroups.com
Thanks,

to be clear - what happen, when 2 clients have different TURN server in peerConnection construction? Will they be able to create connection?

also I read, that when I have more TURN servers in my list, the WebRTC will check them and choose one, that is faster. We have most of customers in EU, our first TURN server was located in the USA, so we crated new one in EU and it is rarely used. 

Thanks,

Jindrich

Kaiduan Xie

unread,
Nov 17, 2014, 10:09:14 AM11/17/14
to discuss...@googlegroups.com
When two PeerConnections are constructed with different TURN servers, the voice/video call can be established if the two TURN servers are reachable from each other, the path for the media will looks like,

1) PeerConnection A <---> TURN port on TURN server A, i.e, 3478
2) allocated port on TURN server A for PeerConnection A, i.e, 5678 <----> allocated port on TURN server B for PeerConnection B, i.e, 6789
3) TURN port on TURN server B, i.e. 3478 <---> PeerConnection B

/Kaiduan


Matthew Kaufman

unread,
Nov 17, 2014, 1:26:19 PM11/17/14
to discuss...@googlegroups.com
Put haproxy in front of it.  

Akshay Kasar

unread,
May 20, 2016, 9:49:29 AM5/20/16
to discuss-webrtc
Hello,

Need your help and suggestions if anyone was successful in achieving this load balancing of multiple TURNs. I am also trying to do something similar

Thanx in advance,
Akshay

Anower Zihad

unread,
Aug 20, 2021, 6:59:53 PM8/20/21
to discuss-webrtc
Please give an update if anyone was able to add multiple turn servers in one system

shakeeb nazmus

unread,
Aug 22, 2021, 11:20:50 AM8/22/21
to discuss-webrtc
>>Please give an update if anyone was able to add multiple turn servers in one system
We use multiple TURN servers in the following ways

1) Client fetches the TURN server's address and credential by calling a REST API.  
2) The REST API chooses the best TURN server based on the Client's Public IP address and the TURN servers' load info.
3) The credential is ephemeral so it expires after 24 hours, Client needs to fetch it again.

This is maybe not the best way to handle this but it is working fine for us.

Thanks,
Shakeeb
Reply all
Reply to author
Forward
0 new messages