I have a single web server reachable from two different public IP addresses (on two separate internet connections), let’s say 192.0.2.1 and 192.0.2.2.
I have added the two A records as suggested here: Round-robin DNS · Cloudflare DNS docs
I noticed that when one connection goes offline, the website always takes 20 seconds to load.
I tried 100 times and 100 times it took 20 seconds. It looks like it waits for the “down” A record even if the other one is working fine.
Is this the expected behavior?
What feature, service or problem is this related to?
Are the records proxied? If not, the process is down to the browser which will receive all the IP addresses that resolve in the DNS and then try them in whatever way it does.
If they are proxied, round-robin DNS doesn’t do any healthchecks so Cloudflare can’t know which connections are up. It will try one (that then seems quite sticky to prevent issues with sessions I assume, I’m not sure of details about how that is done or how long for), then try another.
How long that takes depends on how the server is “down”. If the request traffic is dropped somewhere, then you need to wait for the connection attempt to timeout. If the site is reported as unreachable, actively rejects connections or has an SSL problem, the retry will happen very soon. States that would return Cloudflare 521, 522, 523, 525 or 526 error codes trigger a retry.
How? Unplugged from the LAN, turned off, webserver stopped, blocked by the firewall dropping packets, blocked by the firewall rejecting packets, etc? Any state that needs a timeout in order to confirm will have a delay.