Multiple A DNS records and browser retries failover / redundancy
I wanted to know how firefox / chrome etc behave when there are two A DNS records for a website, and one of those IPs does not respond. The use-case for this is to have the same website hosted in two locations, and when one server/network becomes offline that the other one can take over.
I couldn’t find any up to date info about this so I thought I’d just do some tests and compile my own info. Test case used only two A records for the same hostname.
Browser | Version | Failover OK | Failover Seconds |
Chrome | 75 | Yes | 30 |
Internet Explorer | 11 | Yes | 20 |
Firefox | 68 | Yes | 20 |
MS Edge | 17 | Yes | 8 |
NOTE: If the connection returns an error sooner, presumably these browsers will failover faster. The test here was a complete drop of traffic with no TCP reset/icmp error coming back from the first attempted IP.
Using multiple DNS A records is a plausible failover mechanism in modern browsers!
PROBLEM: Browsers seem to switch between IPs after a period of inactivity (even just a few minutes). If your site requires state, you will need to make state be stored inside the browser (preferably) or some kind of shared state system between servers.
Pros:
Multi-server failover is relatively easy, and fast in modern browsers
Traffic is balanced between both locations
Cons:
If one A record server stops responding, the user may experience a delay when loading the site
If one A record server stops responding while the user was already on the site, they may see an error until they reload the page.
If state required, need to store in browser or shared state system