Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do most browsers behave if they get multiple A-records from the DNS server? Do the stick to one IP as long as it is reachable (and only use another if the IP is down)? Or do they switch all the time for no reason?

If the majority current browsers stick to one IP, DNS-RR would be enough for me as a simple failover solution.

share|improve this question
    
I can't answer your question directly, but I will point out to you that you have to deal with caching at both the browser and the OS level! Have fun :) –  SpacemanSpiff Jan 14 '12 at 20:35
1  
1  
@Iain - Awesome link –  SpacemanSpiff Jan 14 '12 at 21:15
    
How many machines do you have for a backend? If 2 machines with active-passive is okay, get a third IP address, and use heartbeat to failover it between physical machines. Alternatively, I think ultramonkey supports assigning to backends based on source IP, which is almost the same as a single client. You could probably also hack something together by having each backend set a unique cookie, and having a frontend web server proxy to backends depending on the cookie. (Apache's mod_rewrite can probably do it.) –  jon Jan 15 '12 at 22:07
    
There is no single rule covering all browsers, so at the very least you need to specify which one/ones you're interested in. –  John Gardeniers Jan 16 '12 at 22:26

4 Answers 4

edit: Editing my answer since HiPerFreak schooled me.

DNS servers will return a list of all A records it has for a given host name. Where round robin comes in is that it rotates how the list is ordered. The link that lain posted is a great example of how web browsers will make use of that list.

Round Robinning can be used for a very primitive form of load balancing, but is a very poor substitute for real load balancing, since if one of the hosts in the round robin rotation goes down, the DNS server will be none the wiser and will still put the IP address of the downed node in the list.

share|improve this answer
    
The DNS server always hands out ALL addresses. The browser is the one, who decides which one gets used (as discuseed many times here and elsewhere). Also, the OS passes all IPs to the browser. –  HiPerFreak Jan 14 '12 at 21:12
    
@HiPerFreak The often-seen configuration (especially for a large number of A-Records) is that the DNS hands out some addresses (although not all, usually to make sure they fit into a UDP packet of 512 bytes and not incur unnecessary overhead), usually in a changing order. –  the-wabbit Jan 14 '12 at 21:20
    
I was thinking of 2 or 3 IPs. –  HiPerFreak Jan 14 '12 at 21:35
    
@HiPerFreak: I just wanted to say that you are right in that a DNS server does hand out all the A records when queried for a name if multiple A records exist for that name. I have a DNS server and just did a packet capture with Wireshark while I pinged the hostname to confirm. Thank you -- I learned something today! :) –  Ryan Ries Jan 14 '12 at 22:04

See this my question (and answer): How browsers handle multiple IPs.

Shortly - round robin dns does not improve availability at all. Browser chooses one IP and sticks to it, even if it does not responds. (Checked with FF and chrome).

Once browser dns cache expires, hostname resolved again and the process repeated, regardless of did IP answered or not.

For basic HA, you may use dynamic DNS or various IP-based approaches.

EDIT: This behavior will take place when inaccessible host acts as a "black hole". If instead the host ctively refuses incoming connections, browser will try one ip, get refuse and immediately use another ip and thus it will fail-over pretty well.

share|improve this answer

They switch the IPs, it isn't a failover solution.

The browsers let the OS to do the name resolution, and for examle Linux always randomizes the IP addresses, try host google.com several times. The IPs will come in random order.

share|improve this answer
    
Why do they do this randomly and without reason? Wouldn't it make sense to reuse a know-to-work IP as long it is up-and-running? –  HiPerFreak Jan 14 '12 at 20:49
1  
It is for load balancing. –  Stone Jan 14 '12 at 20:52
    
@HiPerFreak See also: en.wikipedia.org/wiki/Round-robin_DNS –  voretaq7 Jan 14 '12 at 21:06
    
@HiPerFreak: THe reason it doesn't stick to a known-to-work IP is that the name resolution knows nothing about whether that IP works now or has in the past. The browser doesn't stick to a single IP, because the name resolution is telling it to use different IPs. :-) –  Sean Reifschneider Jan 15 '12 at 3:22
    
@Sean: As discussed in the blow answer, the name resolution gives the browser ALL IPs and the browser decides, which one to use. And the browser knows which IPs did work and which not. So this cannot be the reason. –  HiPerFreak Jan 15 '12 at 7:40

The DNS return all the IP in a list but they change the order of the list and this order is not random or change when 1 fails but they always return the IPs in the same sequence for load balancing reasons. When the browser receive the list, I suppose it picks the 1st in the list if not known as non-working.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.