– Kamailio SIP Server –

Asterisk Load balancing and High Availability with OpenSER

OpenSER coupled with Asterisk are implemented in many huge installations.

The simplest way to set up load balancing is to use the dispatcher module.

The dispatcher.cfg file should be set up like:

# group  sip addresses of your * units
1 sip:10.1.2.3:5060
1 sip:10.1.2.4:5060
1 sip:10.1.2.5:5060

the basic openser.cfg should be like:

loadmodule("dispatcher.so")

...

if ( method=="INVITE" ) {
# dst_select( "GROUP", "HASH METHOD")
  dst_select("1","4");
  sl_send_reply("100","Trying");
  forward(uri:host, uri:port);
  exit();
}

If you are interested in using the dispatcher to do 300 Redirect, you can do the following:

if ( method=="INVITE" ) {
  dst_select_domain("1","4");
  # you can also add prefixes, if you need to send account codes
  # like:
  # prefix("123456");
  sl_send_reply("300","Redirect");
  exit;
}

in this fashion, you can put in a very inexpensive SER/OpenSER installation to use as a load-balancer for your * units.

SRV Records

Another option is to use SRV records for your asterisk server group and forward the message into the domain.