Outbound Call Load Balancing (alternating servers)

Hello Everyone,

Because of the volume of outbound calls we do, our SIP termination provider has asked us to alternate (load balance) the outbound traffic to two servers. The question is…how?

I’m used to failing over, but not alternating. I thought I’d be creative and use the servers as members in a custom entry in queues.conf and use strategy = leastrecent but didn’t seem to have any luck.

I basically want:
exten => _1NXXNXXXXXX,1,Dial({Alternate between SIP/Server1 and SIP/Server2)

Any suggestions would be appreciated!


Could you do it with groupcount, So when a threshold is reached it uses another route.


Normally I’d agree, but I think it would get pretty ugly when we’re talking about 30-50 simultaneous calls. And it’s not like I can set an outbound limit like 25 on one of the servers to force the remaining calls over to the second, because if one of the servers goes down then the outbound limits will prevent the other one from taking all of the volume.

Fast solution is
1.create sip peer:
2.Create non-public round-robin dns record for trunk.sip.me:
trunk A
trunk A
3.Put on cron job asterisk -rx ‘sip reload’ for every 5-10 seconds.

in final ip address of trunk.sip.me will be change between two or more ips in 5-10 secs interval.

Common solution as i saw is using openser dispatcher.

So, what you digged by own ?

I’ll have to check out OpenSER, I think that might be the ultimate solution.
In the meantime, I’m nervous about constantly running sip reload on Asterisk when there’s going to be constant outbound traffic. Would this scenario work though?


Then create a duplicate hosts file, with the first one pointing provider.fakedomain.blah to the first server IP address, the second hosts file containing the alternate address and use Cron Jobs to copy the hosts file every 5-10 seconds or something.

What do you think?

I think random would be more what you’re looking for, rather than fooling with host files and sip reloads.

For instance:

exten => s,1,GotoIf($[${RAND(0,99)} >= 50]?s|4)
exten => s,2,Dial one sip provider
exten => s,3,Hangup
exten => s,4,Dial other sip provider
exten => s,5,Hangup

So, now there is a 50% chance of dialing either sip provider. Very spaghetti-code-ish, but about as good as you can do given the tools you have.