Can coturn support Anycast IP?

109 views
Skip to first unread message

Anshul Malik

unread,
Jan 28, 2023, 10:39:31 AM1/28/23
to TURN Server (Open-Source project)
Hey, I am curious if turn can be deployed behind anycast. 

Now, I won't consider a turn instance to be stateless since it has allocated some ports to someone and this becomes the state.
I am trying to deploy turns in multiple regions so that I have a turn server close to peer across the world. But I can't give this big list to each peer, I'd ideally want to give all of them one IP address which would connect them to nearest turn.

So, I was thinking anycast can help here, but coturn being stateful, if a turn instance dies, and traffic gets routed to another turn instance, it won't know about the allocations happened on the previous instance, so not sure how that would work.

I'd like to get comments from the community, how to go about it.

Thanks

Gustavo Garcia

unread,
Apr 2, 2023, 7:11:40 AM4/2/23
to TURN Server (Open-Source project)
Yes, anycast can be used with coturn.   For example when you use GCP with premium networking tier for your coturn instance you get anycast automatically for that instance.

To use it with servers in multiple regions and a single IP I think you could get it with a cloud load balancer (check https://cloud.google.com/load-balancing/docs/load-balancing-overview).   But i don't have experience with that deployment.   If somebody can share experiences with this it would be great and we can document it in coturn wiki.

The traditional approach for what you want is using DNS.   You should have turn.mycompany.com with all your TURN servers registering their IPs associated to that domain name (this is simplified explanation).   Then you only need to give that domain name to your clients and when they try to resolve the name they will get the IP of one server close to them.

If a TURN server dies usually the easiest approach is to use an iceRestart (if you are using webrtc/ice) and get a new turn server to handle your traffic.   I wouldn't make it more complicated for a case that is not that common unless you want to be very aggressive with autoscaling servers.

Regards,
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages