AWS TURN server: In 7 Simple Steps
AWS TURN server

AWS TURN server: In 7 Simple Steps

Metered Team

Table of Contents

In this article we will learn how to setup and run a TURN server in AWS in 7 simple steps

TURN servers are used in NAT traversal and are essential in WebRTC and VoIP communications

We will be using CoTURN to setup our TURN server. CoTURN is an open source implementation of TURN server.

There is also an option to use TURN server providers like Metered TURN servers

Prerequisites

We need to have the follow to start building a TURN server in AWS

  • An AWS account
  • Basic Knowledge of how to create an EC2 instance and command line tools
  • Some basic Knowledge of concepts like IP address and protocols

Step 1: Creating an AWS Instance

We need to create an AWS instance to be able to install the coturn to it

Creating an AWS Instance
  1. login to your AWS console and
  2. On the EC2 dashboard click on the 'Launch Instance' button to launch an AWS instance
  3. choose the Debian or Ubuntu operating system
  4. Select the type of instance small or big depending on the TURN traffic that you anticipate (CPU, RAM and Bandwidth requirement vary based on your useage of the TURN server)
  5. Configure the security group to open necessory ports such as port 22 for ssh and port 3478  port 80 and 443 for CoTURN click on 'Review and Next'
  6. Review the settings and launch the instance
  7. then ssh into your instance and move to the step 2

Metered Global TURN servers

  1. Global Geo-Location targeting: Automatically directs traffic to the nearest servers, for lowest possible latency and highest quality performance.
  2. Servers in 12 Regions of the world: Toronto, Miami, San Francisco, Amsterdam, London, Frankfurt, Bangalore, Singapore,Sydney
  3. Low Latency: less than 50 ms latency, anywhere across the world.
  4. Cost-Effective: pay-as-you-go pricing with bandwidth and volume discounts available.
  5. Easy Administration: Get usage logs, emails when accounts reach threshold limits, billing records and email and phone support.
  6. Standards Compliant: Conforms to RFCs 5389, 5769, 5780, 5766, 6062, 6156, 5245, 5768, 6336, 6544, 5928 over UDP, TCP, TLS, and DTLS.
  7. Multi‑Tenancy: Create multiple credentials and separate the usage by customer, or different apps. Get Usage logs, billing records and threshold alerts.
  8. Enterprise Reliability: 99.999% Uptime with SLA.
  9. Enterprise Scale: : With no limit on concurrent traffic or total traffic. Metered TURN Servers provide Enterprise Scalability
  10. 50 GB/mo Free: Get 50 GB every month free TURN server usage with the Free Plan


Step 2 : Connecting to the instance

  1. from the EC2 dashboard select 'Instances' from the left-hand corner and
  2. choose the instance that we created for the purposes of installing CoTURN and select that instance
  3. Follow the instructions to ssh to the server from your local machine

Step 3 : Update the server

When you are able to connect to the server, update and upgrade all its packages by running the below command

sudo apt update
sudo apt upgrade

Step 4 : Installing CoTURN

Once we have installed and updated all the packages. Now it's time to install the CoTURN

Type the below command to install coturn

sudo apt install coturn

Step 5: Configuring CoTURN

open the configuration file of the CoTURN that you have just installed

cd coturn

sudo nano /etc/turnserver.conf

  1. then uncomment the followinf fields by removing the # before them
listening-port=3478
fingerprint
lt-cred-mech
use-auth-secret
static-auth-secret=YOUR_SECRET_KEY
realm=your-domain.com
total-quota=100
bps-capacity=0
stale-nonce
no-loopback-peers
no-multicast-peers

Replace 'YOUR_SECRET_KEY' with a secure key of your own and 'your-domain.com' with your domain and save the file

2. Enable CoTURN on boot by going to

and opening the file

sudo nano /etc/default/coturn

uncomment the 'TURNSERVER_ENABLED=1' and save the file

Step 6: Starting the CoTURN server

you can now start the CoTURN srver by using the below command

sudo systemctl enable coturn

Step 7: Verify the CoTURN server is working

type the below command to verify if the coturn server is working on or not

```bash

sudo systemctl status coturn

```

You will see a message that the CoTURN is running

Bonus: Open Relay Project

While running on aws is a good idea. You can also use the Free TURN server provided by the Open Relay project

you can create an account for the open relay project here

WebRTC Stun Turn Servers | Metered
Add one-to-one or Group Video and Audio Calling to your app or website with Metered Video Call SDK
Metered STUN TURN servers

the server provided by the Open Relay Project has the following features

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
Free WebRTC TURN Server - Open Relay Project | Open Relay Project - Free WebRTC TURN Server
---
Free TURN server

Bonus: Paid TURN Server by Metered Video

Metered Video also provides a TURN server service that is paid. You can use this service if you want a paid TURN service for your application

WebRTC Stun Turn Servers | Metered
Add one-to-one or Group Video and Audio Calling to your app or website with Metered Video Call SDK
Metered TURN server

The plans for the Metered video TURN service starts from 99 USD /mo and here is the complete pricing table

Plan Name Growth Business Enterprise
Price 99 USD / mo 199 USD /mo 499 USD / mo
Included TURN Usage 150 GB / mo 500 GB / mo 2 TB / mo
Overage Charges 0.4 USD / GB 0.2 USD / GB 0.1 USD / GB
Email Support Yes yes yes
Uptime 99.999% 99.999% 99.999%

You can sign up for Metered TURN service here:

WebRTC Stun Turn Servers | Metered
Add one-to-one or Group Video and Audio Calling to your app or website with Metered Video Call SDK

Bonus: Costs and Considerations involved when running an AWS TURN Server

Here are considerations when running your own TURN server on AWS

  1. Installation
  2. Maintenance
  3. Instance limbo problems
  4. costs involved
  5. allocation of resources

1. Installation: Installation is an issue. You need to install your own turn server on aws. AWS does not offer pre built TURN server.

Installing the CoTURN is a difficult task and needs a lot of know how and technical expertise

while using the Open Relay Project is pretty easy and free to use. You can also consider using Metered Video TURN server which is a paid server but has additional features like 99.999% Uptime and email support.

2. Maintenance : One of the major issues when running your own TURN servers is maintenance. Once you have installed the TURN server your work is not done

You still need to maintain all the dependencies and have a look at the resources to ensure that the TURN server is working as it should

Another option is to use the free Open Relay Project, where there is no need to worry about maintenance.

You can also prefer the Metered TURN server which is a paid service that comes with additional features like 99.999% Uptime and email support.

3. Instance Problems : One of the major problems with cloud providers in general and AWS in particular is that the instance goes into limbo and just hangs. The only solution when this happens is to start the instance and face downtime

One of the ways to mitigate this problem is to use the Open Relay Project's Free TURN server or

the Metered Video TURN server which is a paid service but comes with additional features like 99.999% Uptime and email support.

4. Costs Involved : Running TURN server on AWS is an expensive proposition.

TURN server require both a lot of compute power and bandwidth. Both of these things come at a significant costs when purchased from AWS.

Plus there is the headache of running the TURN server and maintaining it.

You can easily use the Open Relay Project's Free TURN server or

the Metered Video TURN server which is a paid server but comes with a added features like 99.999% Uptime and email support.

Conclusion

AWS is an awesome resource for building application but for running a TURN server is a complicated endeavour that can be done for learning purposes

But for production use getting a professional service like Metered TURN server is recommended

Even for casual use or for startups that need a economical service they can turn to the FREE TURN server provided by the Open Relay Project