[Asterisk-Users] IAX1/2 routing/load balancing

Steven Critchfield critch at basesys.com
Thu May 8 11:55:46 MST 2003


It occured to me that now that we have the dbput and dbget commands in
the extension logic, you don't need to sheel out to AGI to do this work
load.

You could easily put some simple logic that holds a pointer, that
pointer points to your server.

something like this in extensions
exten => s,1,DBget(maxrecords=redirect/max)
exten => s,2,DBget(currentpointer=redirect/pointer)
exten => s,3,DBget(iaxurl=redirect/${currentpointer})
exten => s,4,Gotoif((${maxrecords}=${currentpointer})?s|10:s|20)
exten => s,5,hangup ; broken gotoif condition

exten => s,10,DBput(redirect/pointer=0)
exten => s,11,goto(s|30)

exten => s,20,DBput(redirct/pointer=(${currentpointer}+1))
exten => s,21,goto(s|30)

exten => s,30,dial(${iaxurl})


Please scrutinize this logic and it's grammer. I wrote this off the top
of my head, and probably made a few mistakes. This may be susceptable to
race conditions where 2 calls come in close enough together that they
both go to the same URL. Since both calls would do bounds checking, the
pointer shouldn't point beyond usable data, and the next call will be
redirected. This benefits from the ability to add and rearrange the URLs
as needed. You can also add extra load to a site by adding their URL
more than once per cycle.

Hope this helps give you ideas on how to get along to your goal better.

On Thu, 2003-05-08 at 13:03, David Luyens wrote:
> Sorry for not being
> 
> Let me give a real example.
> I have a four E1 GW in Europe which collects all my traffic destined for
> US.
> I have 4x a one E1 GW in the US named 'IAXserverA', etc.
> I want to send the first call towards IAXserverA
> The second to IAXserverB
> The third to IAXserverC
> The fourth to IAXserverD
> The fifth to IAXserverA
> .........
> 
> So all my traffic collected in Europe needs to be spread over the 4
> IAXservers in the US....
> Example:
> Destination NY 212xxxxxx needs to be send to IAXserverA&B&C&D
> Destination SF 415xxxxxx needs to be send to IAXserverA
> .....
> 
> How would I do this?
> 
> David
> 
> -----Original Message-----
> From: asterisk-users-admin at lists.digium.com
> [mailto:asterisk-users-admin at lists.digium.com] On Behalf Of Steven
> Critchfield
> Sent: Tuesday, May 06, 2003 6:33 PM
> To: asterisk-users at lists.digium.com
> Subject: Re: [Asterisk-Users] IAX1/2 routing/load balancing
> 
> 
> On Tue, 2003-05-06 at 11:18, David Luyens wrote:
> > Hi,
> > 
> > 
> > Is it possible to route IAX traffic from 1 IAX server to several other
> 
> > IAX servers in a load balancing pattern. For example I have 3 
> > terminating IAX servers in the US and I want to send all US traffic to
> 
> > those 3 servers equally spread?
> 
> Are you wanting to load balance CPU, bandwidth, or operator time? You
> would possibly tackle these in different manners.
> 
> Most notably, possibly an AGI script that gathered statistics just
> before placing the IAX leg of the call.
> 
> Almost everything is possible from AGI.
-- 
Steven Critchfield  <critch at basesys.com>




More information about the asterisk-users mailing list