Skip to content

Load balancing in Flussonic

Load balancing in Flussonic

Load balancing — process of distributing client requests among servers in a cluster according to some particular algorithm.

Load balancing is aimed to:

  • prevent server overload in a cluster;

  • optimize the usage of the resources in a server cluster;

  • maximize the throughput.

It also provides scalability and redundancy, e.g. you can add servers in a cluster when needed and in case one of the servers is down, the balancer ensures that the load is distributed evenly among other working servers so that it minimizes impact on users.

Flussonic can balance users between multiple Flussonic Media Server nodes. Load balancing is achieved by redirecting client requests to other servers in a cluster.

You can enable load balancing without the use of the IPTV plugin or Catena. It may be configured straight in Flussonic.

There are various load balancing algorithms, which suit best for a particular situation. The choice of the method depends on your needs and goals. There are three load balancing modes in Flussonic:

  • Least Connection (Client) Method:

Directs traffic to the server with the fewest active client connections. Most useful when there is a large number of persistent connections in the traffic distributed unevenly among the servers. No parameters are needed.

  • Least Output Bitrate:

Directs client requests to the less loaded server according to the output bitrate value. max_bitrate (in bit/s, you can also specify it in Mbit/s 40M or Kbit/s 40К) value is required.

Warning

You should specify the max_bitrate value for every peer in a cluster, otherwise, a balancer will not work properly.

  • Bandwidth Usage:

Distributes client requests according to the bandwidth usage of the server. No parameters are needed.

How do you know you need a balancer?

If your streaming platform or service has more than 10 000 viewers, then you should consider it.

To use the balancer add it to the configuration file (/etc/flussonic/flussonic.conf):


balancer lb0 {
  mode bitrate;
  peer p1 max_bitrate=60M;
  peer p2 max_bitrate=40M;
  peer p3 max_bitrate=30M;
}

Parameters:

  • lb is a balancer name.

  • peer is a peer (like peer1.example.com).

  • mode is a balancing mode (bitrate, usage, clients). mode bitrate is used by default.

Example of a URL for a stream channel1 request:

  • http://FLUSSONIC-IP/lb/channel1/index.m3u8

You can configure a few balancers at a time if needed.

Balancer configuration

  1. Define a set of servers to include in the load balancing scheme and specify the same cluster_key in their configuration files to connect them.

  2. Choose a server for load balancing. Configure a balancer with balancer option (do not forget to specify the cluster_key as well):


cluster_key SOME_CLUSTER_KEY;
balancer lb0 {
  mode bitrate;
  peer stream.example.com max_bitrate=60M;
  peer stream.example.tv max_bitrate=40M;
  peer stream.exmpl.com max_bitrate=30M;
}

In the example above we defined a balancer lb0, including 3 servers to balance among by the bitrate value (mode bitrate).

Here is an example of configuration with another balancing mode mode clients (mode usage is configured similarly):


cluster_key SOME_CLUSTER_KEY;
balancer lb0 {
  mode clients;
  peer stream.example.com;
  peer stream.example.tv;
  peer stream.exmpl.com;
}