[Asterisk-Users] DNS load-balancing & SRV records

Curt Moore tgrman21 at hotmail.com
Mon May 10 20:51:53 MST 2004


If only it were that easy. :-)  In the situation you've described, you would 
successfully achieve load distribution but not necessarily load balancing 
and potentially confuse yourself to no end.  This really is an issue of 
semantics in one sense, load balancing vs load distribution.

If all server configs are the same and your third party PSTN device directs 
calls to the realm "company.com", how is asterisk to know to which of the 3 
servers a certain SIP device is registered?  For example, if user A is 
registered to a1.company.com and user B is registered to a2.company.com, if 
user A tries to call user B, since user B is not registered to the same 
asterisk server as user A, the call will be rejected by a1.company.com since 
user B is registered to a2.company.com, unless you set up the system in such 
a way that it tries all 3 servers in succession until it finds the extension 
registered to one of the asterisk servers.  If it's not found at all, then 
hop to voicemail or send a SMS page using the new app_sms or something else 
useful.

Then you must deal with the case of what happens if your third party PSTN 
gateway wants to reach user B but pulls the DNS info for 
asterisk.company.com that points to a1.company.com.  Again, a1.company.com 
knows nothing of user B since this user is registered to a2.company.com.

Also with DNS, you have to remember, once a lookup is done from the SOA, it 
is cached until the TTL expires.  If you have one or more clients sending 
lots of VoIP traffic to an asterisk server and they happen to all pull the 
address of a1.company.com, they will continue to use a1.company.com until 
the TTL of the DNS records expire, usually recommended 6 hours, 21600 sec, 
therefore throttling the server.  This is why round robin is not optimal for 
load balancing as there is no feedback about the actual load of the 
individual servers to the one doing the delegating of traffic to the member 
servers, the DNS server in this case, for the purpose of load balancing.

One thing which comes somewhat closer to actual load balancing for asterisk 
is LVS, depending upon which of the models is used, 
http://www.linuxvirtualserver.org/.  This still has inherent issues which 
are tricky, but not impossible to work around with asterisk.  You still have 
the issue of determining which SIP device is registered with which asterisk 
server but things like app_dbodbc and a little PHP make this lots easier.

-Curt


Let's say I have a third-party device acting as a sip<-->pstn gateway, a
cluster of three asterisk servers, and a teensy bit of dns knowledge.
Let's now say those asterisk servers are a1.company.com at 192.168.0.1,
a2.company.com at 192.168.0.2, and a3.company.com at 192.168.0.3.

1.  If I setup round-robin dns like so:

asterisk.company.com.   IN      A       192.168.0.1
asterisk.company.com.   IN      A       192.168.0.2
asterisk.company.com.   IN      A       192.168.0.3

2.  and normal A records for the servers like this:

a1.company.com.         IN      A       192.168.0.1
a2.company.com.         IN      A       192.168.0.2
a3.company.com.         IN      A       192.168.0.3

3.  and srv records like so:

_sip._udp.company.com IN SRV 20 0 5060 a1.company.com
_sip._udp.company.com IN SRV 30 0 5060 a2.company.com
_sip._udp.company.com IN SRV 40 0 5060 a2.company.com

4.  and configure all my sip clinets to register to asterisk.company.com

5.  and tell the 3rd-party sip<-->pstn gateway to use srv records & that
all inbound calls from the pstn should go to the realm "company.com"

6.  and all the configs on the asterisk servers are identical...

would I have successfully setup load-balancing across my asterisk
servers?



Thanks,
Jeremy
_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

_________________________________________________________________
Best Restaurant Giveaway Ever! Vote for your favorites for a chance to win 
$1 million! http://local.msn.com/special/giveaway.asp




More information about the asterisk-users mailing list