styx
styx copied to clipboard
Evaluate the use of netty's NameResolver and DnsCache instead of InetAddress classes.
The problem
The DNS caching solution in Java is flawed as it does not respect the TTL settings. It could also benefit from alternating the IP addresses in a round robin fashion.
Netty added in 4.1 the interfaces NameResolver and DnsCache (which are marked as unstable ) to provide its own implementation for hostname resolution that should fix these issues.
It seems worth exploring migrating our DNS resolution code to use those classes so Styx doesn't have to rely on performing the actual DNS requests (which can be costly) each time when we need to connect to a pool of servers behind a single host name .