Blog Details
Notes on the TURN Server Location and Logistics
SIP (Session Initiation Protocol) and WebRTC protocols are instrumental in establishing peer-to-peer (P2P) networks for real-time, media-rich applications like streaming, gaming, and video conferencing apps. Both nodes in a P2P network intending to exchange data need each other’s IP address to establish a bi-directional connection.
Sounds easy enough! Except this has a high-security risk. To manage that risk, networks employ network address translation (NAT) which masks IP addresses and breaks P2P media connections. In a NAT dealing, IP addresses are identified and conveyed with STUN, Session Traversal Utilities. STUN works well — except sometimes it does not.STUN will not work with symmetric NAT or when the two peer networks are separated by a firewall. When STUN isn’t working, the connection can’t be established, the application fails, and users get frustrated.
Here, a server using the Traversal Using Relays around NAT (TURN) protocol saves the day, by saving connection. When NAT stops two nodes (networks) from exchanging IP addresses and STUN can’t be an intermediary, IP addresses can be provided to a TURN server — a third party.
The good news!
TURN servers can resolve almost all NAT-related connectivity issues. That said, a lot of traffic gets routed through these servers, with most of the protocols using TURN servers. More heavy loads on the server mean more capital expense on the TURN infrastructure. This also includes many servers situated across the geographic range of the application’s user base.
Optimal application performance depends on having the TURN server’s location. TURN server placement makes a significant difference in user experiences and application performance. It should be on the edge, located closest to the client’s nodes.
Now the question that follows is how to figure out where to place TURN servers?
Determine “closest”?
As said, there should be the nearest proximity possible between your nodes and TURN server(s). This is potentially a complex problem, but there are some basic methods that can be pursued.
- Domain Name System (DNS)
DNS is a worldwide naming service. It maps Internet-connected resources to IP addresses. DNS selects which address to report when a browser requests a server’s IP address.
- Geo IP
As the name suggests, a Geo IP service allows one to input an IP address and obtain location information – like region, country, city, and even latitude and longitude. P.S: We would recommend Geo IP if DNS isn’t available.
- Telemetry
To know where a device is, sometimes you just have to ask. Like how smartphones provide their precise GPS location. Telemetry offers precise guidance on TURN server placement for user groups.
Additional considerations
If the world revolved around app developers, they would make sure user locations will be immediately visible and entirely accurate.
People move around and that mobility means client nodes moving more often than not. Who is connecting and when, changes moment to moment. As a result, the TURN server placement that was working well till sometime back may turn out to be insufficient in recent times.
TURN server location choice is an imprecise science. There exist no precise answer.
Nevertheless, these insightful questions are crucial in the pursuit of picking the right service.
- Availability of the selected solution, geographically and in terms of capacity and scaling?
- Does the solution allow us to add servers?
- Are key regions covered?
- Does the server provider offer any road map on coverage expansion?
Basically, you have to meet your own expected audience and trajectory of your TURN service provider.
Here are our previous blog on WebRTC architecture, TURN and STUN from RTCWeb.in
About RTCWeb.in
RTCWeb.in has been at the forefront of WebRTC development since the advent of this revolutionary technology. Be it about TURN servers or WebRTC development or anything else, our WebRTC experts have got you covered. Contact us now for smooth WebRTC development support.