What is Multi-Level Cluster?
Ant Media Server provides highly scalable solutions with a cluster structure. We have a blog post and documentation about cluster structure. In this blog post, we will introduce a new feature which is the multi-level cluster.
A cluster that has different regions is called Multi-Level Cluster where each region has its own origin for a stream. Ant Media Server can be scaled in different physical locations when you create CDN like a cluster. In this structure, you can distribute the nodes to regions based on their physical location. This has some advantages in performance and data-transfer. Because each region will have its own origin node for a stream, the edges in a region will pull the stream from the origin of their region.
How does it work?
Let’s clarify the case with an example scenario. We have two scenarios
- Publisher & Players in the same cluster
- Publisher & Players in the different clusters
Publisher & Players in the same cluster
Publisher
starts a stream and it is assigned to theOrigin1
instance in theRegion1
Player1
who is geographically closed toRegion1
instance requests to play the stream.Player1
is assigned toEdge11
instance in theRegion1
- Since the
Origin1
is the origin of the stream,Edge11
will pull stream fromOrigin1
.
Publisher & Players in the different clusters
Player2
who is geographically closed toRegion2
requests to play the stream.Player2
is assigned toEdge21
instance inRegion2
Edge21
checks the origin of the stream.- Since there is no local origin instance in
Region2
to pull the stream. It assigns itself as the secondary origin for that stream inRegion2
. Edge21
pulls the stream from theOrigin1
(main origin) inRegion1
.Edge21
sends the stream toPlayer2
.
- Since there is no local origin instance in
Player3
who is geographically closed toRegion2
requests to play the stream.Player3
is assigned toEdge22
inRegion2
.Edge22
checks the origin of the stream. SinceEdge21
is a secondary (local) origin for the stream in theRegion2
, it pulls the stream fromEdge21
and serves toPlayer3
.
In short, each stream is distributed from the main node that was the closest node to the publisher. Also, all regions will have their own secondary (local) origin for a stream if someone close to that region requests to play the stream.
How to configure Multi-Level Cluster?
Region for a node is determined with the nodeGroup parameter. You can set the node group (or region) of a server by adding nodeGroup=GROUP_NAME
in conf/red5.properties
file. Make sure that the instances running in the same region should have the same nodeGroup
value.
Also, this parameter can be set on the fly with the REST method.
Keep in mind that you should configure the Load Balancer to forward Publish and Play requests to the best region. If you have a global cluster in different geolocations, you should have a Load Balancer like AWS Route53 Service.