Regionality
Regionality is a feature that improves clustering performance by allowing each client to select their preferred region. A region is an identifier that represents a geographic area. This allows each client to select a geographic area close to them, which ensures fast connection times and high throughput.
Available Regions
The region identifiers are specific to your application. If your app has many users concentrated in a few areas, you likely have regions with small geographic areas such as chicago or new-york. On the other hand, if you have a global user base, you might want to use regions that represent larger geographic areas such as north-america or europe.
List of Regions
There is no canonical set of regions. Each Media Server can select its own region, and the set of available regions is taken from each Media Server that's connected to the current cluster.
Region Assignment
When a client requests a specific region, the gateway service attempts to assign it to a Media Server in the same region. If there are no available media servers in the requested region, or all of the media servers in the requested region are over capacity, the gateway ignores the region and assigns the client to an available Media Server on a round-robin basis.
This means that a client's selected region is only a preference. Clients requesting a specific region can potentially be assigned to any Media Server in the global pool if no media servers for their region are available.
Set Up Regions
There are two steps to set up regions:
- You must assign a region to each Media Server that uses the regionality feature.
- You must add an extra parameter to your logic that generates the client registration token.
Assign a Region to a Media Server
To assign a region to a Media Server, update the Server-Specific Configuration.
Update the Client Registration Token
Once your pool of media servers has been assigned regions, you must update the client registration logic so that each client requests a specific region. Refer to the Generate Authorization Token Server Side and Use Channels topics. To request a specific region, specify the optional regionId
parameter when you create the client registration token. This parameter comes after the sharedSecret
parameter, and indicates the region that the client would like to be assigned to.
Note
Don't generate the token client side in production. This is for demo purposes only. For more information, refer to the Generate Authorization Token Server Side topic.
For example:
var client = new FM.LiveSwitch.Client("http://localhost:8080/sync", applicationId, userId, deviceId);
string token = FM.LiveSwitch.Token.GenerateClientRegisterToken(
"my-application-id",
client.UserId,
client.DeviceId,
client.Id,
null,
new[] { new FM.LiveSwitch.ChannelClaim(channelId) },
"--replaceThisWithYourOwnSharedSecret--",
"north-america"
);