Enterprise deployment DNS SRV
About
DNS supports SRV records for advertising IPs for a service. These support priorities and weights and are somewhat similar to MX mail server records.
They can be used to provide through DNS one or more IPs for accessing a domain via SIP. IPs can be grouped into priorities which allows primary, secondary etc servers to be specified.
Basic load balancing can be achieved through weightings. However, these are a recommendation to the client and do not take into account actual server load.
Record format
_Service._Proto.Name TTL Class SRV Priority Weight Port Target
Example
All servers listen on port 5060. Ports are specified in the record, so alternative ports can be used.
- sip1, sip2, sip3 are the primary servers. Server sip1 can handle twice as many calls as sip2 & sip3.
- sip4, sip5, sip6 are the secondary servers. Servers sip4 and sip5 can handle twice as many calls as sip6.
- sip7, sip8 are tertiary servers in another data centre. They can all handle the same number of calls.
_sip._udp.mydomain.com. 86400 IN SRV 10 50 5060 sip1.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 10 25 5060 sip2.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 10 25 5060 sip3.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 20 20 5060 sip4.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 20 20 5060 sip5.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 20 10 5060 sip6.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 50 10 5060 sip7.mydomain.com.
_sip._udp.mydomain.com. 86400 IN SRV 50 10 5060 sip8.mydomain.com.
- Failover
- sip1, sip2, sip3 have priority 10, so are the first choice
- sip4, sip5, sip6 have priority 20, so are the second choice if all servers with priority 10 can't be reached
- sip7, sip8 have priority 30, so are the final choice if all servers with priority 10 or 20 can't be reached
- Load balancing
- sip1, sip2, sip3 have total weight of 100. sip1 has weight 50 so gets 50/100=50% of calls, sip2&3 have weight 25 so each get 25/100=25% of calls.
- sip4, sip5, sip6 have total weight of 50. sip4&5 has weight 20 so each get 20/50=2/5 of calls, sip6 has weight 10 so gets 10/50=1/5 of calls.
- sip7, sip8 have total weight of 20. both have weight 10, so get each get 10/20=50% of calls
- Scalability
- Any number of extra hosts can be added to increase capacity
Advantages
- Simple
- Easy to manage
- Requires no extra hardware
- DNS system provides redundancy if DNS server(s) fail through cached copies
- Can spread calls across multiple data centers, including both load shared across data centers or failover from a primary data centre to a backup location.
Disadvantages
- Load balancing is determined by weights so that the caller picks a server to use based on round robin/probability. This means it doesn't take actual server load into account, so you may have find a server overload while there is another server that is almost idle.
- Requires the SIP client to support retrying with another IP
- The lower priority IPs will be tried first, which may increase the PDD while the calls fail if the primary servers are offline
- DNS TTL means it may take some time to update the IPs (a lower TTL avoids this but increases load on the DNS servers)