[asterisk-dev] load balancing / failover support ideas

Stephen Coles scoles at wellpak.co.uk
Fri Dec 12 14:32:16 CST 2008


I need to add multiple internet lines to my asterisk setup [as my
internet connects are slow (DSL distance problem) and I don't want to
pay for a lease line] with load balancing between the lines - googling
and there's no easy/cheap way to do this.  Redundancy\failover seems
just as hard.  So I had some ideas and just wanted to share them, maybe
some people will like them and there get work upon and find their way
into asterisk, just be binned or maybe asterisk can do this already [if
it can sorry].  But here goes:

 

To the iax2.conf I would add:

 

                priority                                 (what order to
use the context in)

                calls_out
(number of call going out allow on this context - before the next group
context is used)

                calls_total
(total number of calls in and out allow on this context - before the
next group context is used)

                loadbalance                                        (true
or false - do i distribute the calls evenly between the group)

                gateway
(what IP address to send the calls out on)

                externip
(needed if behind a NAT)

                localnet
(needed if behind a NAT)

                

then you could dial using:

                Dial(IAX2/GROUP:{first part of context to match}/22122) 

                

e.g.:

                [outbound - voip minutes]

                priority = 1

                loadbalance = yes

                gateway = 192.168.16.5

 

                [outbound - telstar]

                priority = 2

                loadbalance = yes

                gateway = 192.168.16.6

                

                [outbound - voip hip]

                priority = 3

                loadbalance = yes

                gateway = 192.168.16.7

                

then dial using:

                Dial(IAX2/GROUP:outbound/22122)

                

chan_iax2 would work out that I wanted to use a group and use any
context that started outbound so any of the 3 contexts above would be
valid routes.  The routes would be ordered by priority, so chan_iax2
would use voip minutes first, telstar second and voip hip third.
Because I'm using the loadbalance option it will spread the traffic
evenly across the 3 connections.  So if voip minutes current has 2 calls
on, telstar has 1 call on and voip hip has 5 calls on.  A new call would
go out on telstar as this has the least amount of calls.

 

 

this could be expanded upon to do failover by adding a checkroute to
each context above asterisk can every X minutes check that the route is
still valid and if it isn't mark it so it isn't used.

If a call was current in progress and the connection went down, if all 3
contexts were using the same TISP you could reroute the call (using the
unique channel id) over another outbound context to the same TISP match
up the unique call id and the call wouldn't be dropped - this would be
easy to do for the IAX  than the SIP protocol because its owned by
asterisk.  The problem with doing this for the sip protocol is that it's
a standard and would require a RFC (Request for Comments).

 

To make this easier to develop you could you could add it to IAX3 - so
you could ship asterisk and allow the user to use IAX2 or the new
EXPERIMENTAL IAX3 (like you do with the new faster dial plan pattern
matching routine that you need to turn on in extension.conf)

 

Stephen Coles
 IT Services
 Wellpak(UK) Ltd 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20081212/e8b6723f/attachment.htm 


More information about the asterisk-dev mailing list