Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Video Regions and Global Low Latency


(warning)

Warning

This page is for reference only. We are no longer onboarding new customers to Programmable Video. Existing customers can continue to use the product until December 5, 2024(link takes you to an external page).
We recommend migrating your application to the API provided by our preferred video partner, Zoom. We've prepared this migration guide(link takes you to an external page) to assist you in minimizing any service disruption.

(warning)

Warning

Twilio is launching a new Console. Some screenshots on this page may show the Legacy Console and therefore may no longer be accurate. We are working to update all screenshots to reflect the new Console experience. Learn more about the new Console(link takes you to an external page).


Overview

overview page anchor

Programmable Video Developers can select the geolocation of the Twilio infrastructure that serves their Rooms. Two mechanisms are available:

  • Explicit region selection
  • Global Low Latency (GLL)

Understanding these mechanisms is important for creating high quality Real-Time Communication (RTC) applications.



On the Internet, latency and packet loss depend on geolocation. When the connection between a sender and a receiver spans the globe, latency and jitter are increased by the distance between the parties. Packet loss is also more likely, due to the number of routers in the connection path. This affects quality in several ways:

  • Signaling messages will have higher latency, increasing the time for Participant operations like connecting to a Room, and sending and receiving the first media samples.
  • After joining, publishing and subscribing to new Tracks will take longer.
  • In Group Rooms media latency will increase and media fidelity will decrease.

In order to minimize these effects, the Twilio infrastructure that serves a Room should be as close as possible to the Room's Participants. This guide provides best practices and recommendations on how to choose regions for your applications.


Programmable Video developers have the following options when working with regions:

Region IDLocation
gllGlobal Low Latency (see section below)
au1Australia
br1Brazil
de1Germany
ie1Ireland
in1India
jp1Japan
sg1Singapore
us1US East Coast (Virginia)
us2US West Coast (Oregon)
Twilio Video Regions.

Twilio Programmable Video regions are architected around two concepts: the Signaling Region and the Media Region.

The Signaling Region:

  • It is a per-Participant property. Hence, each Participant may have a different Signaling Region.
  • It is the ingress / egress point for the Participant's signaling traffic and Twilio's cloud.
  • The Participant's TLS encryption session is terminated at the edge Server.

The Media Region:

  • It is a Room level property. Hence, all the Participants in a Group Room share the same Media Region.
  • It is the location of the Server where media processing takes place.
  • Each Participant's DTLS encryption session is terminated at the Server.

Unless there are legal or compliance reasons, developers should select the region having less latency with a Participant as the Signaling Region of that Participant.

For the Media Region, we recommend to use the region minimizing the average latency to all the Group Room Participants. Many times it's not possible to have prior knowledge of a participant's location. In that case, a simple rule of thumb that typically works is to select the region closest to the first Participant.

Applying these recommendations may be complex and sometimes developers prefer Twilio to select the region on their behalf. This can be achieved using GLL (Global Low Latency).


Selecting the Signaling Region (WebRTC Go, P2P, and Group Rooms)

selecting-the-signaling-region-webrtc-go-p2p-and-group-rooms page anchor

Our Video SDKs use gll as the default Signaling Region. In that case, Participants will connect to the region having minimum latency to their location. This can be overridden with Signaling Region selection, which is supported in the following SDK versions:

Twilio Video SDKRequired version
Androidv5.0.0-beta1+
iOSv3.0.0-beta1+
JavaScriptv2.0.0+

The Signaling Region can be specified using the region property at connect time. For example, the following snippets illustrate how to connect to de1:

Android (v5.0.0-beta1+)

Java


_10
ConnectOptions connectOptions = new ConnectOptions.Builder(accessToken)
_10
.region("de1")
_10
.roomName("my-room")
_10
.build();
_10
_10
room = Video.connect(context, connectOptions, roomListener);

Kotlin


_10
val connectOptions = new ConnectOptions.Builder(accessToken)
_10
.region("de1")
_10
.roomName("my-room")
_10
.build()
_10
_10
room = Video.connect(context, connectOptions, roomListener)

iOS (v3.0.0-beta1+)


_10
let connectOptions = ConnectOptions(token: accessToken) { (builder) in
_10
builder.region = "de1"
_10
builder.roomName = "my-room"
_10
}
_10
self.room = TwilioVideoSDK.connect(with: connectOptions, delegate: self)

JavaScript (v2.0.0+)


_10
const { connect } = require('twilio-video');
_10
_10
const room = await connect(token, {
_10
name: 'my-room',
_10
region: 'de1'
_10
});


Selecting the Media Region (Group Rooms)

selecting-the-media-region-group-rooms page anchor

Using the Console

By default, your Twilio account is configured with us1 as the Media Region. You can modify the default media region in Video/Rooms/Settings(link takes you to an external page), as the following picture illustrates:

Video Console Region Selection.

Using the Rooms API

You can override the default region specified in the console by using the Rooms REST API. This can be done by setting the MediaRegion POST parameter to the desired Region ID. For further information see the Room Creation Example.


Understanding GLL: an Example

understanding-gll-an-example page anchor

Current Twilio region selection is based on two principles:

  • When the Signaling Region is gll then the region with minimum latency to the client is selected for signaling traffic.
  • When the Media Region is gll then the Signaling Region of the first participant connecting to the Group Room is selected for media traffic. Note, that due to this, in ad-hoc Rooms Media Region can be specified at connect time from the first Participant SDK.
(information)

Info

Why does gll sometimes pick servers so far away from me?

  • We use latency based routing, which is different from location based routing; sometimes the DNS answer may return a server, which is not geographically closest.
  • The returned server may also be affected, if a VPN is being used

Let's use an example to better illustrate how this works. Imagine a Group Room with the following participants:

  • Alice connects first from New York (lowest latency region is us1 )
  • Then Markus connects from Berlin (lowest latency region is de1 )

The following table shows the actual chosen regions as a function of the specified (at the console or with the APIs) Signaling and Media Regions:

Specified Media RegionSpecified Signaling Region (Alice)Specified Signaling Region (Markus)Chosen Media RegionChosen Signaling Region (Alice)Chosen Signaling Region (Markus)
---us1us1de1
gll--us1us1de1
gllgllgllus1us1de1
ie1--ie1us1de1
gllie1-ie1ie1de1
gllie1gllie1ie1de1
ie1au1br1ie1au1br1

Twilio's Programmable Video SDKs must communicate with Twilio's cloud. Hence, firewalls may need to be configured to allow Twilio's Signaling and Media Servers IPs:

  • Developers using explicit regions should whitelist the IP ranges in their selected Media and Signaling regions.
  • Developers using gll should whitelist the IP ranges in all regions.

The IP ranges and domain names assigned to every region can be found in our IP Addresses Guide.


Rate this page: