You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by mmg <ma...@gmail.com> on 2010/07/07 16:08:19 UTC

Very slow HttpServletRequest.getLocalName()

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?

Thanks,

Mathias
-- 
View this message in context: http://old.nabble.com/Very-slow-HttpServletRequest.getLocalName%28%29-tp29096652p29096652.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Very slow HttpServletRequest.getLocalName()

Posted by Rainer Jung <ra...@kippdata.de>.
On 07.07.2010 18:03, mmg wrote:
>
> Hi Rainer,
>
> Thanks for that suggestion, but it's not my code that's calling the method:
> it's the icefaces framework so it's out of my control.

If you don't find a good other solution, you can write a simple filter, 
that registers a ServletRequestWrapper, so all calls to getLocalName() 
go through your wrapper which can then do something more suited to your 
needs instead of simply calling super.getLocalName().

To add the filter you have to add the new classes to the webapp and add 
the filter configuration to web.xml of the webapp, but you don't have to 
change any existing code or similar of the webapp.

Regards,

Rainer

> Rainer Jung-3 wrote:
>>
>> On 07.07.2010 16: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?
>>
>> You might want to try getLocalAddr (if IP is enough) or getServerName()
>> (if a host header is set by the client and that header is fine).
>>
>> Regards,
>>
>> Rainer
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>

-- 
kippdata
informationstechnologie GmbH   Tel: 0228 98549 -0
Bornheimer Str. 33a            Fax: 0228 98549 -50
53111 Bonn                     www.kippdata.de

HRB 8018 Amtsgericht Bonn / USt.-IdNr. DE 196 457 417
Geschäftsführer: Dr. Thomas Höfer, Rainer Jung, Sven Maurmann
===============================
kippdata
informationstechnologie GmbH   Tel: +49 228 98549 -0
Bornheimer Str. 33a            Fax: +49 228 98549 -50
D-53111 Bonn                   www.kippdata.de

HRB 8018 Amtsgericht Bonn / USt.-IdNr. DE 196 457 417
Geschäftsführer: Dr. Thomas Höfer, Rainer Jung, Sven Maurmann


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


Re: Very slow HttpServletRequest.getLocalName()

Posted by mmg <ma...@gmail.com>.
Hi Rainer,

Thanks for that suggestion, but it's not my code that's calling the method:
it's the icefaces framework so it's out of my control.

Mathias


Rainer Jung-3 wrote:
> 
> On 07.07.2010 16: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?
> 
> You might want to try getLocalAddr (if IP is enough) or getServerName() 
> (if a host header is set by the client and that header is fine).
> 
> Regards,
> 
> Rainer
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Very-slow-HttpServletRequest.getLocalName%28%29-tp29096652p29098130.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Very slow HttpServletRequest.getLocalName()

Posted by Rainer Jung <ra...@kippdata.de>.
On 07.07.2010 16: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?

You might want to try getLocalAddr (if IP is enough) or getServerName() 
(if a host header is set by the client and that header is fine).

Regards,

Rainer

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


Re: Very slow HttpServletRequest.getLocalName()

Posted by mmg <ma...@gmail.com>.
Thanks for your suggestion. I will ask the system admin to add this entry.
The ip address is 69.90.208.57


awarnier wrote:
> 
> 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?
>> 
> Have you tried putting a specific entry in your local /etc/hosts file,
> which will match 
> what the lookup is looking for ?
> (what is the IP address by the way ?)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Very-slow-HttpServletRequest.getLocalName%28%29-tp29096652p29096953.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


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


Re: Very slow HttpServletRequest.getLocalName()

Posted by André Warnier <aw...@ice-sa.com>.
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?
> 
Have you tried putting a specific entry in your local /etc/hosts file, which will match 
what the lookup is looking for ?
(what is the IP address by the way ?)


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


Re: Very slow HttpServletRequest.getLocalName()

Posted by Pid <pi...@pidster.com>.
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
> 



Re: Very slow HttpServletRequest.getLocalName()

Posted by André Warnier <aw...@ice-sa.com>.
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.

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


Re: Very slow HttpServletRequest.getLocalName()

Posted by Pid <pi...@pidster.com>.
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


p