Open weissi opened 2 years ago
SwiftNIO has never really done round-robin DNS, that's correct. I think this is ultimately a dupe of #536: getaddrinfo
is out of scope for us to change, and locally shuffling the DNS results does not necessarily achieve a round-robin effect. We could in principle work around this by shuffling the results of the lookups, but it's not straightforwardly clear that the increased computation effort is worthwhile.
Thanks @Lukasa, that all makes sense. I personally wouldn't dupe it because at least to me it was news that GAI doesn't RR and this might be a problem that someone is actually experiencing.
Regarding the shuffling or not: I'd personally say that shuffling it is worth the effort (especially because it can be done off-EL) but I can understand your position too.
TIL that apparently,
getaddrinfo
does not do DNS round-robin'ing because apparently it sorts the results.If true that would mean that SwiftNIO programs that don't change the default resolver -- which is to say most SwiftNIO programs -- will always pick the same IP address for a given host name.
I didn't check to see if that's true but it seems likely because the Happy Eyeballs code seems to take the IP addresses in order (merging IPv6 and IPv4 addresses).