Details:
When I resolve my domain name hosted on cloudflare, out of the 2 A record IPs one of them is always down. This causes the browser to timeout if it tries that particular IP, before moving to the next IP and slowing the website.
dig <my_domain_name>.com
; <<>> DiG 9.10.6 <<>> my_domain_name.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13332
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;<my_domain_name>.com. IN A
;; ANSWER SECTION:
<my_domain_name>.com. 300 IN A 172.67.175.186
<my_domain_name>.com. 300 IN A 104.21.35.142
;; Query time: 214 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Jan 20 00:10:43 IST 2022
;; MSG SIZE rcvd: 72
Out of which 104.21.35.142 is down
:~ root$ ping 104.21.35.142
PING 104.21.35.142 (104.21.35.142): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^C
--- 104.21.35.142 ping statistics ---
3 packets transmitted, 0 packets received, 100.0% packet loss
:~ root$ ping 172.67.175.186
PING 172.67.175.186 (172.67.175.186): 56 data bytes
64 bytes from 172.67.175.186: icmp_seq=0 ttl=59 time=23.392 ms
64 bytes from 172.67.175.186: icmp_seq=1 ttl=59 time=22.775 ms
^C
--- 172.67.175.186 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 22.775/23.084/23.392/0.309 ms
And when the IP 104.21.35.142 is accessed by the browser, it waits for it to timeout before trying the other one which works.
This can be seen with curl command
:~ root$ curl -v <my_domain_name>.com
* Rebuilt URL to: <my_domain_name>.com/
* Trying 104.21.35.142...
* TCP_NODELAY set
* Connection failed
* connect to 104.21.35.142 port 80 failed: Operation timed out
* Trying 172.67.175.186...
* TCP_NODELAY set
* Connected to <my_domain_name>.com (172.67.175.186) port 80 (#0)
> GET / HTTP/1.1
> Host: <my_domain_name>.com
> User-Agent: curl/7.54.0
> Accept: */*
...
<my_domain_name> is not my actual domain name, but is used to mask the actual domain name.
I have noticed this particular IP is provided when the DNS proxy is enabled.
As a stop-gap solution, I have disabled the DNS Proxy for the affected domains which unfortunately causes the DNS to respond with the domain where my ‘pages’ is hosted but resolves faster than a timeout.