- Prefer IPv4
Starting with version 4, Java performs both IPv6 and IPv4 DNS lookups. If the DNS server is not set up to properly respond to IPv6 queries, then Java will wait for the IPv6 query to time out. This can manifest in what looks like network slowdowns.
To bypass IPv6 DNS lookups, set the Java System property java.net.preferIPv4Stack to true.
Command line: -Djava.net.preferIPv4Stack=true Java:
System.setProperty("java.net.preferIPv4Stack",
"true"); - Increase cache time
When a Java 6 security manager is not set, the default DNS cache is 30 seconds. To reduce network DNS queries, the number of seconds of DNS cache can be increased by setting the networkaddress.cache.ttl System property. Set this property to -1 to never expire the DNS cache.
Command line: -Dnetworkaddress.cache.ttl=-1
Java:"-1");System.setProperty("networkaddress.cache.ttl",
2013-01-13
Optimize Java DNS Lookup
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment