Load balancing 4 asterisk boxes

Is there anything special that needs to be done to load balance 4 asterisk boxes?

I can deploy as many boxes as want but I need a way for them to all share the same IP.

i’ve tried this with heartbeat but it seems only outbound calls seem to work and the inbound calls don’t. (I’m really trying to upgrade the current system to be able to handle many calls and reduce the amount of traffic that hits the old box)

Does anyone know how to achieve this?

I too am interested :question:


I thunk it’s not asterisk related.
Try ultramonkey.

Try one of the available sip proxies out there. openser/opensips/kamailio They can do load balancing, failover etc between the asterisk servers.

One of OpenSIPS/OpenSER/Kamillo is going to be your solution. If you wanted to load balance 4 asterisk boxes, you would need 5 public IP addresses:

1 - OpenSIPS
2 - Asterisk1
3 - Asterisk2
4 - Asterisk3
5 - Asterisk4

You would ‘advertise’ the OpenSIPs IP address as your SIP gateway address. So if you had a carrier who was going to send you calls, you would give them that IP.

The OpenSIPs server has a module called dispatcher which is very powerful. You can configure it to forward the INVITE requests to your asterisk servers using a few different algorithms (i.e. round-robin, weighted, etc).

OpenSIPs does have a bit of a learning curve, but it is EXTREMELY powerful and compliments asterisk beautifully.

Agreed with the above. We use OpenSER which is now call Kamillo to do “load balancing”. The reason for the quotes is because its limited load balancing. For calls that needs to go into an ACD queue, it has to always goto the same asterisk server otherwise your calls will be out of order. Until Asterisk somehow shares queue information across multiple asterisk servers, you cannot load balance calls with queues.

If you are not using ACD queues, then yeah load balancing works great. We have hundreds of phones registered to OpenSER. Some other features may be limited also such as parking a call but i think there should be ways around that with asterisk dialplan programming to check multiple asterisk servers where the call is at.

I’m confused now!!

There is openSips and kamailio.

I’ve tried the opensips before but failed, crashed and burned due to lack of information and documentation not being as sourceful as asterisk.

I’ve done as you suggested and downloaded OpenSips again but now I search for readable documentation so I can learn the syntax, everything points to kamailio.

I really like what I’ve read so far on both and certainly like the prepaid features (something i’ve been waiting to implement) and the registar.

I really now want to full implement this so my asterisk boxes take less of a hit but I don’t have any sense of direction when it comes to which of the two projects above i need to start with.


Thanks guys.

OpenSIPS has great documentation and samples. Like I said, there is a bit of a learning curve, but the effort pays off 10 fold.

OpenSIPS documentation is broken down into some categories.

There are the core functions and parameters:
opensips.org/index.php?n=Res … sCoreFcn14

There are the ‘modules’ which extend the core and provide the majority of the functionality:
opensips.org/index.php?n=Res … sModules14

The general documentation index can be found here:
opensips.org/index.php?n=Res … sCookbooks

I would venture to say that the documentation for OpenSIPS is far superior to that of Asterisk. Once you figure out how all the pieces fit together, the documentation is VERY helpful.


Kamillo and OpenSIPS are forks of the same code base… I believe they both came from the now defunct OpenSER project.

Thanks, lol i should know better, I’ve built a new VM to test on so I will digest all info and try to make some sense of it all. it’s utterly confusing from asterisk but the code there seems to be C based so I should understand it easier.

Thanks All…and let ensure that we donate to asterisk so one day it’s the all-in-one solution as it’s mush simpler to deploy.

:laughing: lol my 1st asterisk box took me 20mins this opensips taken me 2hours and i’ve not even started. :open_mouth:

On the same topic is this possible…

An agent registers to OpenSIP

Asterisk1 has queues for clients A,B,C

Asterisk2 has queues for clients D,E,F

SIP calls come in trunk and land in queues

Agent services client A and client D

Can asterisk “know” the state of the SIP device for agent A so that calls from Asterisk1/QueueA and Asterisk2/QueueD, which agent is both a member of, do not present at the same time?

there are functions devstate() and extstate() which give you the state of a device.

That works in the dial plan, but I’m not sure if it works with the queue application.

Not much of an answer really, but it may be of some use to you.