Digital Ocean is a premier Cloud Server provider.
Cloud servers can be used for a variety of purposes and today we are going to learn about TURN servers and how to set up a TURN server in Digital Ocean
Here is a broad list of things we are going to cover
- What are TURN servers?
- Step 1: Creating a VM
- Step 2: Installing TURN server
- Step 3: Testing the TURN server
What are TURN servers?
WebRTC communication requires traffic to be relayed through servers if connection can not be established due to firewall or NAT
TURN servers are required to act as an intermediary to transfer data from one peer to another when the devices are behind separate NATs
The TURN servers have become increasingly essential as WebRTC communications have become popular
Metered TURN server
Metered TURN servers is a TURN server provider. An alternative to creating a TURN server on Digital Ocean you can subscribe to Metered TURN server service
- API: TURN server management with powerful API. You can do things like Add/ Remove credentials via the API, Retrieve Per User / Credentials and User metrics via the API, Enable/ Disable credentials via the API, Retrive Usage data by date via the API.
- Global Geo-Location targeting: Automatically directs traffic to the nearest servers, for lowest possible latency and highest quality performance. less than 50 ms latency anywhere around the world
- Servers in 12 Regions of the world: Toronto, Miami, San Francisco, Amsterdam, London, Frankfurt, Bangalore, Singapore,Sydney (Coming Soon: South Korea, Japan and Oman)
- Low Latency: less than 50 ms latency, anywhere across the world.
- Cost-Effective: pay-as-you-go pricing with bandwidth and volume discounts available.
- Easy Administration: Get usage logs, emails when accounts reach threshold limits, billing records and email and phone support.
- Standards Compliant: Conforms to RFCs 5389, 5769, 5780, 5766, 6062, 6156, 5245, 5768, 6336, 6544, 5928 over UDP, TCP, TLS, and DTLS.
- Multi‑Tenancy: Create multiple credentials and separate the usage by customer, or different apps. Get Usage logs, billing records and threshold alerts.
- Enterprise Reliability: 99.999% Uptime with SLA.
- Enterprise Scale: With no limit on concurrent traffic or total traffic. Metered TURN Servers provide Enterprise Scalability
- 50 GB/mo Free: Get 50 GB every month free TURN server usage with the Free Plan
- Runs on port 80 and 443
- Support TURNS + SSL to allow connections through deep packet inspection firewalls.
- Support STUN
- Supports both TCP and UDP
You can check out the Metered TURN server
Step 1: Creating a VM on Digital Ocean
First we need to create an account on the Digital Ocean website
go to digitalocean.com and create an account. Once you have created an account you will land up in the dashboard area
There you can create an instance called a droplet in digital ocean
Click on the create button on the top corner and select a droplets
then select a location where you want the TURN server to be
then select a operating system any linux preferable Debian or Ubuntu
select a dedicated server for better performance and TURN servers require a lot of CPU and RAM
then we have our droplet or server instance
step 3 Installing the turn server
Next ssh into your machine and type the below commands to install the coturn (free and open source turn server)
sudo apt update
and
sudo apt upgrade
then install the coturn
sudo apt-get install coturn
Now you have installed the coturn. let us start the coturn whenever the server starts
go to file etc/default/coturn
sudo nano /etc/default/coturn
and un comment the line
TURNSERVER_ENABLED=1
and save the file and start the server and thats it
systemctl start coturn
that's it now we have an up and running coturn server
Step 4: Testing the TURN server
You can check whether the turn server is running or not using the Trickle ICE and turn server testing website and some other methods
go to the Trickle ICE website and enter the information
https://www.metered.ca/turn-server-testing
Now you have created a TURN server in Digital Ocean
You can also use the pre built TURN server service Metered
Benefits of using Metered Over Digital Ocean
- Reliability
- Scalability
- Costs
- Maintenance
- DDoS Protection
1. Reliability
Reliability is a major factor when deciding whether to build your own TURN server in cloud or purchase a third party service like Metered
Digital Ocean is one of the premier cloud providers but one of the issues in using cloud server is that they could go in limbo
limbo is a state where the instance or the droplet stops responding and needs to be restarted
which results in disruption of service, which you absolutely do not want if you are running a business
This is an issue with all cloud providers and not just Digital Ocean
While TURN services like Metered provide a 99.999% Uptime that is 5 nines. This is one of the best in the industry
2. Scalability
Scaling TURN servers is a task on its own. TURN servers require quite a lot of CPU and RAM as all the data that is going through them is encrypted
Thus you have created an droplet which is fine for normal use but throttles during peak times etc
and if you want to scale up, you need to create a new instance shut down the old one and face some downtime
While Metered TURN servers auto scales to any amount of bandwidth and you don't even need to worry about scalability etc
3. Costs
Running on cloud providers such as digital ocean is quite expensive.
Instance costs are expensive plus you need to pay for the bandwidth as well
and it is difficult to estimate the cost as well.
As requirements change the need for the size of droplets and bandwidth changes as well
So, you might end up with a large droplet that wastes money or a smaller than required droplet that you give you performance issues
Even on dollar by dollar cost metrics the Metered TURN server is cheaper by for than digital ocean
Metered cheapest plan offers 150 GB of TURN use for 99 USD / mo and 0.4 USD per GB after that
there are volume discounts available as well up to 0.1 USD per GB
Lets look at the cost of creating a TURN server on Digital Ocean
Creating a general purpose CPU instance with 4 cores and 16 GB will cost 126 USD / mo plus bandwidth
you might think with more usage your costs might go down in digital ocean but that is not the case
because with more usage you will require a bigger instance or droplet to handle the data going through the sever
4. Maintenance
With TURN server as with any application you need to maintain it.
You will need to update all the dependencies and might even need to restart the server from time to time
With Metered TURN servers that is all handled with.
You don't need to bother with any maintenance or any such thing just plug and play
5. DDoS Protection
TURN servers are prone to DDoS attacks as hacks use a technique called TURN amplification to attack other servers using any TURN servers that they find on the internet
so with Digital Ocean you might even need to purchase a DDoS protection as well
otherwise you are a sitting duck. You are good until you are found by an attacker after that you need to shut down your server and create another one or purchase expensive DDoS protection which might run into thousands of dollars
Open Relay Project
If you are looking for a free solution, you can consider the Open Relay Project
They provide a free turn server that is production ready and bypasses most corporate firewalls
50 GB of TURN usage is free every month with the Open relay project
Here are some of the features of Open Relay Project
Open Relay is a free TURN server provided by Metered Video that you can use in your WebRTC applications. The Open Relay TURN server is highly available, reliable and offers both STUN and TURN Capabilities.
The Open Relay runs on port 80 and 443 to bypass corporate firewalls, many corporate/enterprise firewall only allow port 80 or 443, it also supports turns + SSL for maximum compatibility.
✅ Runs on port 80 and 443
✅ Tested to bypass most firewall rules
✅ Enterprise grade reliability (99.999% uptime)
✅ Support TURNS + SSL to allow connections through deep packet inspection firewalls.
✅ Support STUN
✅ Supports both TCP and UDP
✅ Dynamic routing to the nearest server
✅ Production Ready
Conclusion
In this article we explained how to install and run your own turn server on Digital Ocean
We also gave options and alternatives to running a server on Digital Ocean
- Metered TURN server: Excellent paid turn service for 0.4 USD per GB
- Open Relay Project: Free TURN server with up to 50 GB free TURN use every month
I hope this article works for you. Thank you for reading
Top comments (1)
check out the metered TURN server