servlets slow when disconnected

B

Bura Tino

Hi,

This may be a total misposting. If so, please indicate a better place to
post.

I have a WinXP machine, whose name is "mymachine" and it's running Tomcat
3.2, . The way I view web pages is through explorer by typing
http://mymachine/servletconext.

1. If I *have* any kind of net connection, the response is instanteneous.
2. If connections are *disabled*, the response is also instanteneous.
but...
3, If all of my connections are enabled but are *down* it takes about 30
seconds for the server to respond.

A few things indicate that it's a servlets issue. a. "ping mymachine" is
always perfect b. I have an apache server running and that responds
instantly, c. I can tell that the servlet engine receives the request
instatly also since it starts compiling the page - but then it takes it's
sweet time in responding.

(There's another way this problem manifests itself. If my lan connection is
up, but the wireless connection is enable but down, the same problem
sometimes persists. This is an even bigger problem since my client base is
affected by it!!!)

Any ideas at all?

Very many thanks in advance!

Bura
 
B

Bura Tino

I've discovered another detail. What I described was correct - there is
about a 30 second delay. What I've discovered is that there's about a 15
second delay before the servlet is executed, then the servlet is executed
(thats <.1sec) and then there's another 15 second delay.

Also, this is not a browser issue since using wget leads to the same
behavior!

Once again, thank for you help. Any thought is appreciated!

Bura
 
S

Sudsy

Bura Tino wrote:
A few things indicate that it's a servlets issue. a. "ping mymachine" is
always perfect b. I have an apache server running and that responds
instantly, c. I can tell that the servlet engine receives the request
instatly also since it starts compiling the page - but then it takes it's
sweet time in responding.

Please take time to consider your viewpoint before claiming that "it's a
servlets issue". In fact, it's a network issue. Look into resolver and
how it works. Also investigate DNS and BIND. Analyze the timeouts and
then tell us all that it's all due to Java and servlets...
You won't, because you can't.
You've actually identified the problem source but you're putting the
blame on the wrong component. Re-read your posts. It's obviously a
network-related problem.
But don't fret: you're not the first person to suggest that the
problem is in the wrong place. Look at how many posters think that
they've found a bug in the language/compiler when, in fact, they
just haven't been using the tools properly!
 
C

Chris Smith

Bura said:
A few things indicate that it's a servlets issue. a. "ping mymachine" is
always perfect b. I have an apache server running and that responds
instantly, c. I can tell that the servlet engine receives the request
instatly also since it starts compiling the page - but then it takes it's
sweet time in responding.

All those things indicate that it's a problem in a code path that
involves the servlet container... but not that the servlet container is
at fault. In fact, the most likely scenario is that the servlet
container is trying to do exactly as you tell it to: log the hostname of
the client. Unfortunately, when you've got a network interface down, it
can't find its default DNS server so you need to wait for the DNS
timeout.

Solution: either fix your DNS, or disable logging of hostname.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
B

Bura Tino

Chris Smith said:
All those things indicate that it's a problem in a code path that
involves the servlet container... but not that the servlet container is
at fault. In fact, the most likely scenario is that the servlet
container is trying to do exactly as you tell it to: log the hostname of
the client. Unfortunately, when you've got a network interface down, it
can't find its default DNS server so you need to wait for the DNS
timeout.

Solution: either fix your DNS, or disable logging of hostname.

I must begin by admitting that I pick things up as I need them (which is
probably not the best approach, but to me that's life). So even though I've
been writing servlet applications for a couple years now, I'm not quite sure
what the word container means in the context of servlets and not quite sure
what it means that it's logging the hostname of the client. Can you direct
me a source so I can educate myself? (And maybe you can just tell me how to
disable hostname logging...)

As far as DNS, and I apologize if this is becoming increasingly ot, how come
a disabled connection times out faster than a "media disconnected"-type
connection. Also, what's so difficult about resolving "localhost"? And what
makes me very curious is why dumb things like outlook and explorer time out
instanteneously and the servlet container takes 15 seconds (and does it
twice)?

Very many thanks for your response (and the one by Sudsy)!

Bura
 
S

Sudsy

Bura Tino wrote:
I must begin by admitting that I pick things up as I need them (which is
probably not the best approach, but to me that's life). So even though I've
been writing servlet applications for a couple years now, I'm not quite sure
what the word container means in the context of servlets and not quite sure
what it means that it's logging the hostname of the client. Can you direct
me a source so I can educate myself? (And maybe you can just tell me how to
disable hostname logging...)

Common servlet containers include Tomcat, WebSphere and WebLogic.
Which are you using? I use Apache backed by Tomcat, BTW.
As far as DNS, and I apologize if this is becoming increasingly ot, how come
a disabled connection times out faster than a "media disconnected"-type
connection. Also, what's so difficult about resolving "localhost"? And what
makes me very curious is why dumb things like outlook and explorer time out
instanteneously and the servlet container takes 15 seconds (and does it
twice)?

If the interface is down then you'll get immediate notification when
you try to connect. If the cable is unplugged then you'll eventually
time-out after the retries complete. Retries are part of the protocol
and part of the reason why networks are so robust.
Let's not forget, Ethernet was designed to be able to survive nuclear
war...
 
C

Chris Smith

Bura said:
I must begin by admitting that I pick things up as I need them (which is
probably not the best approach, but to me that's life). So even though I've
been writing servlet applications for a couple years now, I'm not quite sure
what the word container means in the context of servlets and not quite sure
what it means that it's logging the hostname of the client. Can you direct
me a source so I can educate myself? (And maybe you can just tell me how to
disable hostname logging...)

The container is the software that actually accepts connections from the
networks and calls your servlets. Examples include Tomcat, JRun, Caucho
Resin, Jetty, and more. J2EE application servers such as WebLogic,
WebSphere, or Sun ONE App Server also contain a servlet container as a
component of the larger system. Do you know which container you are
using?

The rest of your questions depend on which container you're using.
Depending on which one you're using, I may or may not be able to answer
it.
As far as DNS, and I apologize if this is becoming increasingly ot, how come
a disabled connection times out faster than a "media disconnected"-type
connection.

A disabled connection doesn't exist as far as TCP/IP is concerned, so it
won't even try the connection. (Indeed, it couldn't.) If you've got a
cable unplugged, then the link exists, but just times out. That's the
difference.
Also, what's so difficult about resolving "localhost"?

This depends on your network situation. Chances are, what's being
resolved is your external IP on the network interface of the client.
And what makes me very curious is why dumb things like outlook and
explorer time out instanteneously and the servlet container takes 15
seconds (and does it twice)?

Simple. Outlook and IE aren't doing DNS lookups on your client IP
address. DNS behaves notoriously poorly when it can't find an answer
and it thinks it can find an answer from some server that's not really
available.

The delay happening twice (i.e., before and after the request is
handled) is likely due to the specific logging configuration in your
servlet container.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
C

Christophe Vanfleteren

Sudsy said:
If the interface is down then you'll get immediate notification when
you try to connect. If the cable is unplugged then you'll eventually
time-out after the retries complete. Retries are part of the protocol
and part of the reason why networks are so robust.
Let's not forget, Ethernet was designed to be able to survive nuclear
war...

Minor nitpick: it was the internet as a whole that was designed for this
purpose.
Ethernet is just a LAN technology that has its roots in Alohanet (which was
radio based). Any protocol could be run over Ethernet, but nowadays, TCP/IP
is the most common one ofcourse.
 
C

Chris Smith

Sudsy said:
Let's not forget, Ethernet was designed to be able to survive nuclear
war...

Well, to be specific, TCP/IP was designed to be able to survive nuclear
war. Ethernet was barely designed to survive a couple dozen people in
an office, and has required constant tweaking to remain reliable.
Luckily, most of the heavy-traffic parts of the Internet are not running
on Ethernet networks... only the leaf sites with somewhat limited usage
can afford to use a collision-recovery based protocol like Ethernet.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
B

Bura Tino

Chris Smith said:
The container is the software that actually accepts connections from the
networks and calls your servlets. Examples include Tomcat, JRun, Caucho
Resin, Jetty, and more. J2EE application servers such as WebLogic,
WebSphere, or Sun ONE App Server also contain a servlet container as a
component of the larger system. Do you know which container you are
using?

The rest of your questions depend on which container you're using.
Depending on which one you're using, I may or may not be able to answer
it.

I use tomcat 3.3.2 with apache. (Could never figure out how to integrate
later version of tomcat with apache.)
 
J

John C. Bollinger

Bura said:
I must begin by admitting that I pick things up as I need them (which is
probably not the best approach, but to me that's life). So even though I've
been writing servlet applications for a couple years now, I'm not quite sure
what the word container means in the context of servlets and not quite sure
what it means that it's logging the hostname of the client. Can you direct

You really should read the servlet spec (available free from Sun). You
will likely find some interesting things there that help you to develop
more efficient servlets and webapps, and that may even give you insights
into how to do some things that you didn't even know were possible. It
will also define the relevant terminology for you.

Anyway, the servlet container is the software that provides the context
in which your servlets run; in your case, the relevant servlet container
is one of the main subsystems of Tomcat.
me a source so I can educate myself? (And maybe you can just tell me how to
disable hostname logging...)

As far as DNS, and I apologize if this is becoming increasingly ot, how come
a disabled connection times out faster than a "media disconnected"-type

If the network interface is actually shut down at the OS level then the
OS knows not to attempt to use it. If it is up at the OS level but not
functioning (e.g. because a cable is not connected) then the OS cannot
make the same assumption. If it can detect the problem at all then it
must suppose that the service interruption may be temporary -- that is
what you are instructing it to do by leaving the interface up despite
the unavailability of the network. This is also generally what you
want, because it allows the OS to handle short service interruptions
gracefully. You especially want that for wireless connections.
connection. Also, what's so difficult about resolving "localhost"? And what

You didn't indicate that you were connecting via "localhost", you
indicated that you were using the machine name. If
http://localhost/servletconext in fact exhibits the same behavior then
your system probably has a buggy or misconfigured resolver library.
Indeed, it should be possible to configure the resolver to recognize the
local machine name without going to DNS / WINS / whatever, which ought
to adress the problem you described, but that is somewhat machine-specific.
makes me very curious is why dumb things like outlook and explorer time out
instanteneously and the servlet container takes 15 seconds (and does it
twice)?

Perhaps Outlook and Explorer leverage Windows-specific API to test and
handle the situation? Understand that those are clients, designed to
operate in a client-type environment where funny business with network
connections is much more likely to occur. Servlet containers are
intended for server-type environments, where availability of the network
is a prerequisite for correct function. A server cannot serve without
the network.


John Bollinger
(e-mail address removed)
 
S

Sudsy

Christophe said:
Sudsy wrote:
Minor nitpick: it was the internet as a whole that was designed for this
purpose.
Ethernet is just a LAN technology that has its roots in Alohanet (which was
radio based). Any protocol could be run over Ethernet, but nowadays, TCP/IP
is the most common one ofcourse.

As soon as I posted I realized that I meant TCP/IP, not Ethernet.
Ethernet is just CSMA-CD. Thanks for clarifying for others.
 
S

Sudsy

Bura Tino wrote:
I use tomcat 3.3.2 with apache. (Could never figure out how to integrate
later version of tomcat with apache.)
<snip>

Okay, so now we're getting somewhere! Look in your
$APACHE_HOME/conf/httpd.conf file for HostnameLookups.
I have it set to Off so no DNS resolution is attempted.
Worth a try?
 
B

Bura Tino

Sudsy said:
Bura Tino wrote:

<snip>

Okay, so now we're getting somewhere! Look in your
$APACHE_HOME/conf/httpd.conf file for HostnameLookups.
I have it set to Off so no DNS resolution is attempted.
Worth a try?

Certainly does!
 
B

Bura Tino

John C. Bollinger said:
direct

You really should read the servlet spec (available free from Sun). You
will likely find some interesting things there that help you to develop
more efficient servlets and webapps, and that may even give you insights
into how to do some things that you didn't even know were possible. It
will also define the relevant terminology for you.

Anyway, the servlet container is the software that provides the context
in which your servlets run; in your case, the relevant servlet container
is one of the main subsystems of Tomcat.


If the network interface is actually shut down at the OS level then the
OS knows not to attempt to use it. If it is up at the OS level but not
functioning (e.g. because a cable is not connected) then the OS cannot
make the same assumption. If it can detect the problem at all then it
must suppose that the service interruption may be temporary -- that is
what you are instructing it to do by leaving the interface up despite
the unavailability of the network. This is also generally what you
want, because it allows the OS to handle short service interruptions
gracefully. You especially want that for wireless connections.
what

You didn't indicate that you were connecting via "localhost", you
indicated that you were using the machine name. If
http://localhost/servletconext in fact exhibits the same behavior then
your system probably has a buggy or misconfigured resolver library.
Indeed, it should be possible to configure the resolver to recognize the
local machine name without going to DNS / WINS / whatever, which ought
to adress the problem you described, but that is somewhat machine-specific.

Perhaps Outlook and Explorer leverage Windows-specific API to test and
handle the situation? Understand that those are clients, designed to
operate in a client-type environment where funny business with network
connections is much more likely to occur. Servlet containers are
intended for server-type environments, where availability of the network
is a prerequisite for correct function. A server cannot serve without
the network.

Thank you. Very good advice.
 
R

Roedy Green

Well, to be specific, TCP/IP was designed to be able to survive nuclear
war.

But not terrorist attack. It never dawned on the designers that the
enemy would be given connectivity on a plate.
 
B

Bura Tino

Sudsy said:
Bura Tino wrote:

<snip>

Okay, so now we're getting somewhere! Look in your
$APACHE_HOME/conf/httpd.conf file for HostnameLookups.
I have it set to Off so no DNS resolution is attempted.
Worth a try?

Actually it's already said to "off". But could this affect the behavior of
tomcat? Actually, my apache server responds instantly under all conditions.
It's the servlets display the behavior I was talking about.
 
C

Chris Smith

Bura said:
Actually it's already said to "off". But could this affect the behavior of
tomcat? Actually, my apache server responds instantly under all conditions.
It's the servlets display the behavior I was talking about.

No, that won't affect Tomcat, but it was worth a shot. The equivalent
configuration in Tomcat is in TOMCAT_HOME/conf/server.xml. (Replace
TOMCAT_HOME with the location you installed Tomcat, of course.) Find
the Valve element with the attribute:

className="org.apache.catalina.valves.AccessLogValve"

And make sure it also has (or add, if it doesn't):

resolveHosts="false"

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top