Implement RFC 6555, Happy Eyeballs
IPv6 is (sadly) not always available. This makes machines that support both IPv4 and IPv6 to perform a little slower when the IPv6 connections are blocked. To prevent such slowdowns, there exists a simple algorithm called "Happy Eyeballs". In essence, it says, one must try to resolve both DNS A
and AAAA
records in parallel and choose the first one to respond.
Here is the RFC that describes this algorithm: https://tools.ietf.org/html/rfc6555 Another blog post about why Happy Eyeballs makes sense: https://daniel.haxx.se/blog/2012/01/03/getaddrinfo-with-round-robin-dns-and-happy-eyeballs/