How does Firefox DNS cache work with multi A records?
Hi Everyone,
I'm trying to understand how Firefox works internally when querying its DNS cache regarding domains with multi A records, this means a domain with more than one IP associated, like www.google.com.
Facts: - The SO has priority when resolving DNS and sends his cache content to the browser when asked. It sends ALL IPs associated to a requested domain. - Firefox's cache then has all IPs for every domain and calls the shots. - DNS Timeouts change per browser, in Firefox I've seen some domains have 4 minutes of TTL, others even less (1 minute TTL) - If I open Firebug plugin I can see the "IP Address" field in each request and see which IP was resolved per domain
Scenario 1: - I hit www.google-analytics.com (which has 12 defined IPs, found it in chrome's dns cache: chrome://net-internals/#dns, or querying the OS: nslookup www.google-analytics.com in a Mac Console ) - Then one IP is resolved and the SAME will be used during the 4 minutes the cache lasts (as validated with trial and error) - After 4 minutes the dice is thrown again and any other of the 12 IPs may be returned when hitting the URL again. (in one test I got IP finishing in 58, second hit IP finishing in 56, they are not ordered either)
Scenario 2: - I hit www.livenation.com and then filter for hits to www.google-analytics.com to see which IPs are used through AJAX in all the multiple hits - Then one IP is resolved and the SAME is used for all google-analytics hits during the 4 minutes the cache lasts.
Scenario 3 (Exactly SAME as 2): - I hit www.livenation.com and then filter for hits to www.google-analytics.com to see which IPs are used through AJAX in all the multiple hits - Then different IPs are defined for different AJAX hits of www.google-analytics.com, seamlessly random. In every request each AJAX hit will be resolved to a different IP (or repeat some, with no pattern). Behavior will keep going until 4 minutes come by and the DICE of DNS is rolled again.
Conclusions and Questions: - Scenario 2 and Scenario 3 are easy to reproduce but it's not deterministic, every 4 minutes Firefox seems to choose whether to use ONE or ALL IPs during the period and then if it's ALL, it throws a new decision dice on EVERY hit. What is Firefox's internal behavior regarding reading its own DNS cache? - Does this mean that if my site has multi-record DNS then there is no level of IP stickiness? - Is there any pattern on how it happens? The context path is used?
NOTE: I've seen this happen both in Firefox and Chrome and both in MAC and Windows. I've validated this behavior in many multi-record domains, including www.google.com, google-analytics, assets.livenation.com, twitter.com, etc.
Any help or insight on this is MOST appreciated. Don't hesitate to ask if you need more details on this. Thanks! Federico
All Replies (1)
Maybe check the Firefox source code.