tags:

views:

268

answers:

2

I used 5 threads to create new InetSocketAddress and store them in queue, but i found it is not enough. How to do a faster dns lookup?

+1  A: 

Isn't a single thread enough for DNS lookup? because DNS Lookup just need to send a request to a DNS server to translate a domain name to IP address, once you get it, its should store by your OS for later use.

S.Mark
i need the result as soon as possible, but the process of DNS lookup is so slow.
bruce dou
the process of DNS lookup need a request to DNS server, if DNS server is far from you, it will take time.
S.Mark
I have lots of domain names to process, more threads is OK?
bruce dou
different domain names and using thread is fine.
S.Mark
@Bruce - if the domains are far away from you or are very slow to reach/respond, then yeah, threads will help you. But be mindful that you are throwing software at what seems to be a network topology or architecture issue. You need to find out first why the DNS look ups are taking so long (and whether indeed the speed you are trying to get is even possible.) Are the DNS in your subnet? Are there firewalls in between? Are all nodes (client include) using the same type of duplex (full vs half)? You gotta root cause it before throwing software at it.
luis.espinal
A: 

The speed of DNS lookup is most likely limited by the speed of your local DNS server and/or the network bandwidth and latency between it and the remote DNS servers you are talking to.

From Java, you may be able to get more InetSocketAddress's created (more DNS lookups done) by spawning more threads, but sooner or later you will run into external limits that become increasingly difficult to get around.

Question: why are you needing to create large numbers of InetSocketAddress objects?

EDIT - Based on your reply, I'm assuming these InetSocketAddress objects are all for the same remote host, and your want them fast to make application startup fast. In that case, you could avoid repeating the DNS lookup by fishing the IP address out of the first InetSocketAddress created and using that IP address to create the remaining InetSocketAddress objects.

Question 2: boosts the speed of what? Are you trying to talk to lots of servers at the same time? Why?

Stephen C
Creating more InetSocketAddress seems boosted the speed.
bruce dou