3

I need an equivalent to java.net.InetSocketAddress that can resolve the host name asynchronously. I'm developing a polling program that must resolve and connect to over 25,000 servers every five minutes indefinitely without a large memory or CPU footprint.

These servers are selected from a database, looped through, and connections are dispatched through the Netty Library. Everything that Netty does is highly efficient and satisfactory, however the thread that loops through and creates InetSocketAddress instances to pass to Netty is being bottlenecked by the DNS resolutions (as the hostname is looked up on initialization of the InetSocketAddress). My temporary solution is to create a thread pool that does the DNS resolving, but I would much prefer an actual asynchronous DNS resolution library.

Thanks!

Blake Beaupain
  • 638
  • 1
  • 6
  • 16
  • What difference are you expecting to see between an "async DNS resolution library" and a manually managed thread pool? – Arash Shahkar Nov 01 '12 at 22:13
  • 2
    probably no good news: http://stackoverflow.com/questions/11955409/non-blocking-async-dns-resolving-in-java – irreputable Nov 01 '12 at 22:53
  • Arash Shahkar: Better throughput, less memory usage – Blake Beaupain Nov 02 '12 at 01:26
  • Probably all has been already said in the link. However, the most versatile and high-performance solution I can think of, is a manual implementation of DNS resolves on top of NIO. Just like any other case, you should try the simpler solution (thread pool executor) and only change it if it's not good enough. – Arash Shahkar Nov 02 '12 at 08:06

0 Answers0