tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: Very slow HttpServletRequest.getLocalName()
Date Wed, 07 Jul 2010 16:41:53 GMT
On 07/07/2010 17:36, André Warnier wrote:
> Pid wrote:
>> On 07/07/2010 15:08, mmg wrote:
>>> Hello,
>>>
>>> I've recently deployed an application on our Linux staging server; a
>>> Tomcat
>>> 5.5.28 server on Java 1.5.0_09-b01. At some point, the application
>>> makes a
>>> call to request.getLocalName(). For some reason, this call takes a
>>> very long
>>> time (about 20 seconds!). I profiled the application, and I see that
>>> tomcat
>>> calls InetAddress.getHostName() in turn. This performs a reverse DNS
>>> lookup.
>>> It's this reverse DNS lookup that takes so long (since our host
>>> doesn't have
>>> a DNS address the resolve fails).
>>>
>>> Is there a way to disable this reverse DNS lookup in Tomcat or is there
>>> anything else I can do to speed this up?
>>
>> It's nothing to do with Tomcat.
>>
>> There are JVM settings which apply to networking & DNS lookups.  You
>> might be affected by these, depending on your system configuration.
>>
>>  http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html
>>
>>
> That is an interesting page per se, but I don't see anything there that
> seems related to the inverse DNS lookup which the application seems to
> be triggering.

Maybe it's trying a dud ip6 connection first.


p

> To complete my earlier suggestion of adding a corresponding line to
> /etc/hosts, like
> 
> 1.2.3.4  somename.localdomain
> 
> (replacing the first part by the real IP address of the host)
> 
> which will work if the system's resolver is configured (in
> /etc/nsswitch.conf) to look at that file first.
> But if it does not, there are more things you can do at the system level :
> 
> 1) change nsswitch.conf to indeed do "files" first
> OR
> 2) make the above change to /etc/hosts AND
> run a local dnsmasq daemon (with the configuration options to have it
> read /etc/hosts) and set /etc/resolv.conf to have this line first
> nameserver 127.0.0.1
> 
> This last is a gain anyway in terms of efficiency, because dnsmasq will
> cache the resolved entries and avoid further lookups into /etc/hosts
> (and other DNS lookups, such as if the application is also doing client
> address lookups e.g.).
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



Mime
View raw message