hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bindul Bhowmik <bindulbhow...@gmail.com>
Subject Re: Advantages of using DNSResolver
Date Sat, 04 Nov 2017 22:29:05 GMT
On Fri, Nov 3, 2017 at 10:11 AM, Guru Prashanth Thanakodi
<tguru.ece@gmail.com> wrote:
> Hi
> I saw that connectionManager constructor  is taking DNSresolver as
> parameter . There are two types of DNSresolver namely
> SystemDefaultDNSResolver and InMemoryDNSresolver. When does Apache
> httpClient uses these class? If my request url has IPinstead of hostname
> will this DNSresolver class still be used?Do I get optimization if I load
> the InetAddress once and reuse them?

HttpClient uses the SytemDefaultDNSResolver by default. If you need to
customize your dns lookups, you can of course create your own
DNSResolver or use the InMemoryDNSResolver. The
SystemDefaultDNSResolver uses the underlying JRE DNS resolver, which
provides caching in most implementations. Someone with deeper
information into the code can correct me, but as far as I understand
even if you use an IP address, the DNSResolver will be called, but the
method the system default DNS resolver calls -
InetAddress.getAllByName [1] knows if the value passed is an IP
address rather than a hostname, and actually does not do any lookup.

You can of course do pro-active or cache backed DNS resolution and
hook in your own implementation, and again I do not know the details
of your implementation, but you may be missing out on an advantage of
the DNS system - for hosts to be able to move or even provide load
balancing.

>
> Thanks,
> Guru

Regards,
Bindul


[1] https://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getAllByName-java.lang.String-

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message