Load Balancing

 

Load balancing is good to use when you want to spread the load across multiple end points. This allows you to share the load an not have one end point processing a disproportional amount of calls. To load balance NSG uses mod_distributor which basically returns a randomly selected string from the load balance list you provide. Below is more details and how to implement it. 

  1. The dial plan is located at

 /usr/local/nsg/conf/dialplan/default.xml, edit this file and use the example below to implement load balancing across multiple TDM groups (SS7 or PRI).

  <action application="set" data="pri_group=${distributor(pri)}"/>
  <action application="log" data="info Selected PRI Group: ${pri_group}"/>
  <action application="bridge" data="freetdm/${pri_group}/a/$1"/>

 

 2. The example below to implement load balancing across multiple SIP devices.

  <action application="set" data="sip_trunk=${distributor(sip)}"/>
  <action application="log" data="info Selected PRI Group: ${sip_trunk}"/>
  <action application="bridge" data="sofia/internal/$1@${sip_trunk}:5060"/>

 

 3. Below is how to define the different strings that will be substituted when 

${distributor(X)} is called. This file should be located at /usr/local/nsg/conf/autoload_configs/distributor.conf.xml and in most cases will need to be created. 

<?xml version="1.0" encoding="UTF-8"?>
  <configuration name="distributor.conf" description="Distributor Configuration">
    <lists>
      <list name="pri" total-weight="2">
        <node name="g2" weight="1" />
        <node name="g3" weight="1" />
      </list>
      <list name="sip" total-weight="2">
        <node name="1.1.1.1" weight="1" />
        <node name="2.2.2.2" weight="1" />
      </list>
    </lists>
  </configuration>

 
  1. Ensure you edit the

 /usr/local/nsg/conf/autoload_configs/modules.conf file and add the line below so this way mod_distributor is loaded when NSG starts. 

 

More Info 

When ${distributor(pri)} is called in the set function this load balances between the different items in the list for "pri". Each item there has a weight and most of the time this will be evenly weighted. In this case above this means ${distributor(pri)} will evaluate to "g2" or "g3" as these are the two items in the list. For the SIP example ${distributor(sip)} will evaluate to 1.1.1.1 or 2.2.2.2. 

Depending the knowledge of the NSG dial plan some items above may be unclear. If you have any questions please contact support support.sangoma.com.

 

 

Return to Documentation Home I Return to Sangoma Support