12
votes

Can someone direct me to information on exact browsers behavior when browser gets multiple A records for a given hostname (say ip1 and ip2), and one of them is not accessible.

I interested in EXACT details, like (but not limited to):

  1. Will browser get 2 IPs from OS, or it will get only one ?
  2. Which ip will browser try first (random or always the first one) ? Now, let's say browser started with the failed ip1
  3. For how long will browser try ip1 ?
  4. If user hits "stop" while it waits for ip1, and then clicks refresh
    • which IP will browser try ?
  5. What will happen when it times-out - will it start trying ip2 or give error ? (And if error, which ip will browser try when user clicks refresh).
  6. When user clicks refresh, will any browser attempt new DNS lookup ?

Now let's assume browser tried working ip2 first.

  1. For the next page request, will browser still use ip2, or it may randomly switch ips ?
  2. For how long browsers keep IPs in their cache ?
  3. When browsers sends a new DNS request, and get SAME ips, will it CONTINUE to use the same known-to-be-working IP, or the process starts from scratch and it may try any of the two ?

Of course it all may be browser dependent, and may also vary between versions and platforms, I'd be happy to have maximum of details.

The purpose of this - I'm trying to understand what exactly users will experience when round-robin DNS based used and one of the hosts fails.

Please, I'm NOT asking about how bad DNS load balancing is, and please refrain from answering "don't do it", "it's a bad idea", "you need heartbeat/proxy/BGP/whatever" and so on.

6
  • 1
    There's a browser extension for Firefox that shows the IP address(s), as well as which IP address is currently being used (addons.mozilla.org/en-US/firefox/addon/showip/?src=search). You can also use Firebug's 'Net' tab to show the IP requests were served by. Obivously this is only relevant to Firefox but I believe Chrome dev console shows the IP requests were served by.
    – user80776
    Nov 4, 2011 at 10:07
  • Also note that some ISP's DNS servers will only ever return one IP address, why they do this I have no idea
    – user80776
    Nov 4, 2011 at 10:08
  • Thanks Sam. And yes, chrome console shows DNS lookups, cache and shows which IP is requested.
    – Sandman4
    Nov 4, 2011 at 14:33
  • If you want to talk about exact behaviour then the first thing to note about how web browsers deal with a records is that they don't. Name resolution is handled by the networking stack. So are you trying to ask about some specific browser oddity you've noticed or are you asking about name resolution?
    – Rob Moir
    Nov 5, 2011 at 16:46
  • Browsers DO receive (from networking stack) multiple IPs listed in A records for a hostname. In Google Chrome, try chrome://net-internals/#dns and see yourself.
    – Sandman4
    Nov 5, 2011 at 17:28

2 Answers 2

5
votes

After all, I had to do the "research" myself. Here's Chromium (version 12.0.742.112) behavior (running on ubuntu 11.04):

Generally it works so: try 1-st ip, once it times-out (after 189 sec.) try 2-nd ip. No error messages given until all ips tried. Next connection will start from first ip again (even if it just failed a second ago and the second ip worked - browser doesn't care)

One interesting thing - TCP connection attempt aren't dropped when user hits cancel - i.e. when I hit cancel, and after 60 seconds click retry, page will show in 130 seconds (189 from the first attempt.) But if I click cancel and click refresh after 190 seconds, the process will start from the beginning.

Regarding the items in the original Question:

  1. Browser gets both IPs from OS, OS doesn't change the order of IPs.
  2. Browser always tries to connect to ip that appears first
  3. It tries for 189 seconds
  4. On 2-nd attempt, it will try first IP again.
  5. When first IP times-out, browser silently continues to the second ip. If it works - the page shows-up, if not - waiting continues.
  6. Not tested. This blog states Chrome caches DNS for just up to 1 minute, when we look at chrome://net-internals/#dns :

    Capacity: 100 Time to live (ms) for success entries: 60000 Time to live (ms) for failure entries: 0

If the first IP works, process will be the same and it will always succeed on the first attempt.

3
votes

Instead of telling people what you don't want, why not explain what it is you are trying to achieve ?

If all you're after is known data, then go and investigate yourself, or read the documentation of whatever browser (there are hundreds) you are talking about.

It may help you to know that this has nothing to do with DNS, though.

If a browser gets a request, it first looks in its various caches to see if the URL, or if not the URL then the hostname, is already present.
If not, it will hit the system resolver to resolve the hostname.

If the IP it gets back does not respond, it will most certainly cache this internally as a negative lookup result, so directly requesting the same URL again in the hopes of hitting a different A record for it will probably serve no purpose, since it will have stored the hostname result along with the negative IP result.

Or, you know, you could provide more information.

EDIT: I see you did provide some information in between all the demanding and smartassery.

Very well:

  1. If the browser asks the system resolver for a hostname, it will get back whatever information there is for that hostname. If that means 2 IPs, then it will return 2 IPs.
  2. That depends on the browser.
  3. That depends on the browser, but all browsers I have ever used do a single request, and will time out after the standard TCP CONNECT() timeout; I'm fairly certain there's an RFC about that somewhere...
  4. That depends on the browser. It has nothing to do with DNS or networking.
  5. No.
  6. No.

You also seem not to know that DNS records are cached everywhere, especially on clients. These records expire, depending on what the domain owner intended or the caches in between you and him configured. One hour to one day is common, so don't expect the resolver to do another DNS query if you hit refresh like a madman.

2
  • 2
    Added explanation of what I'm trying to achieve. I am after known data, I hoped someone knows because it may take days to find the relevant info. Demanding ? I'm asking for information I need, I can't demand - everybody is free to answer or not. Smartassery ? I hurt by your post and I don't think I deserve it.
    – Sandman4
    Nov 5, 2011 at 16:33
  • 1
    I just didn't want the discussion to turn into flame against DNS load balancing. Anyway, thanks for pointing me to TCP CONNECT().
    – Sandman4
    Nov 5, 2011 at 16:40

Not the answer you're looking for? Browse other questions tagged .