Link to home
Start Free TrialLog in
Avatar of lloyd142
lloyd142Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Problems with IIS, isapi_redirect.dll and Tomcat under high load

I have a Java application running on Tomcat 5.5 on a Win2k box. The box runs IIS 5 connected to Tomcat using JK 1.2. During periods of our highest load (around 50 page requests per minute) we have a failure. User's get a browser error (I think it's page unavailable) looking like the application has gone down.

In the IIS logs I can see requests still coming in as expected, and IIS still serves up images ok. Also if I log into the server and connect to Tomcat directly on port 8080 I can load the application (albeit without images) and confirm it is still running correctly.

The only way to rectify the fault is to restart Tomcat, even though this seems to still be running ok

I have turned on logging to debug for the JK connector but can't see anything useful in the logs. I have also tried upgrading JK to the latest version of the DLL (7th aug '07).

If anyone has any recommendations for what I can try I'd be very grateful. Thanks
Avatar of mrcoffee365
mrcoffee365
Flag of United States of America image

We have run that configuration, and 50 requests per minute doesn't sound like too much for the IIS-Tomcat connector.

However, the isapi jk connector behaves oddly, in my opinion.  There are some ways to increase the connections between IIS and Tomcat which might help (didn't make a lot of difference for us, but we can hope).
Try setting cachsize=100 in your workers.properties file:
worker.ajp13w.cachesize=100

It has been recommended by Mladen Turk for Windows/IIS jk connector configurations (it has to be one of the Windows servers, not XP or other non-server OS).

General doc on connectors:
http://tomcat.apache.org/faq/connectors.html
http://tomcat.apache.org/connectors-doc/


Mladen Turk's article on fronting Tomcat with various Web servers, incl. IIS, is a good one for understanding what the Tomcat and connector developers intended:
http://people.apache.org/~mturk/docs/article/ftwai.html

People in Microsoft land would recommend upgrading to Win2003 server and IIS6, and they have improved the thread and caching model in IIS6.

Have you checked the Tomcat logs to see if you can find anything happening there that seems odd?
Avatar of lloyd142

ASKER

Thanks very much for your comments and the links. I agree the number of requests is not high at all.

I'll try the cache size change see if that has any effect. If that doesn't, I guess the IIS/Windows upgrade is the next step.

There's nothing unusual in the Tomcat logs. All we see is page requests which suddenly stop with no error. Then after that the only debug is from a scheduled task which is part of the application which keeps going proving Tomcat on its own is fine.

I'll have to wait for a recurrence (or hopefully not) of this issue to see whether any of these solutions has worked

Your error actually sounds as if IIS can't make any more connections to Tomcat.  So it might be the IIS-to-isapi connector connection that is the problem.  In which case, you might look at connection times and your keepalive values for the IIS-to-connector configuration.

For example, if all your IIS connections via ISAPI are used up (I'm not sure this is possible, but it might be), then the next request for a connection from IIS to Tomcat will get a 500 or 503 -- internally to IIS or the connector -- until the existing connections have been freed by IIS (or the connector -- again, I'm not sure which is holding the connection here).

If you haven't researched this, David Wang's articles on IIS and ISAPI are very informative.  This is one on running JSP from IIS:
http://blogs.msdn.com/david.wang/archive/2005/10/11/How_does_JSP_work_on_IIS.aspx
Hi - thanks again for your reply. The application has been relatively stable recently but failed again yesterday so first I will try and alter the cache size.

How do I select suitable values for connection timeout and keepalive? Do you think I should set all three properties at once (cachesize, cache_timeout, socket_keepalive) and try that or just the cache size for now?

Also I checked yesterday and can confirm it is a 500 error. It's as if Tomcat is unavailable (which it isn't) so agree it looks very much as if IIS can't make another connection to Tomcat
Hard to say, but I'd try just changing cachesize first.
As an update to this, I've now tried changing the cachesize to 100 with no improvement. I have not yet tried to alter timeout or keepalive, I guess this might be the next step.

 I've also been able to extract some debug from the asapi log file which I hadn't previously been able to see:
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [info] jk_connect.c (473): connect to 127.0.0.1:8009 failed (errno=61)
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [info] jk_ajp_common.c (891): Failed opening socket to (127.0.0.1:8009) (errno=61)
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [info] jk_ajp_common.c (1311): (ajp13) error connecting to the backend server (errno=61)
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [info] jk_ajp_common.c (2085): (ajp13) sending request to tomcat failed,  recoverable operation attempt=1
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [debug] jk_connect.c (357): socket TCP_NODELAY set to On
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [debug] jk_connect.c (455): trying to connect socket 11252 to 127.0.0.1:8009
[Sat Nov 24 12:52:05.406 2007] [3324:5284] [debug] jk_ajp_common.c (1058): received from ajp13 pos=0 len=8188 max=8192

Open in new window

These are hard to debug, but we don't get the errors you're getting, with the same W2k/IIS5/Tomcat5.5 architecture.  We have much higher loads at times than you're describing.

Since you're seeing the ISAPI logs, then IIS is making the request to ISAPI, but Tomcat is refusing them (occasionally).

errno 61 seems to mean, usually, that Tomcat isn't started.  

Maybe if you post your workers.properties and uiworkermap.properties files, we can make more suggestions.
Tomcat is definitely started up as I can access it directly over port 8080

Here are my workers.properties, server.xml(part of) and uiworkermap.properties. If you can spot any obvious differences between mine and your setup that would be very useful. Thanks
# workers.properties -
workers.tomcat_home=E:\Apache Group\Tomcat 5.5
logfiles_home=E:\logs\tomcat
workers.java_home=D:\Program Files\j2sdk1.4.2_02
 
ps=\
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.cachesize=100
 
 
 
 
 
 
 
Part of server.xml:
 
<!--
    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
 
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" 
               minProcessors="5" maxProcessors="75" enableLookups="true" 
               redirectPort="8443" acceptCount="20" useURIValidationHack="false" 
               debug="0" connectionTimeout="60000" protocol="AJP/1.3" />
 
 
 
uiworkermap.properties:
 
/broker=ajp13
/broker/*=ajp13

Open in new window

We have set some slightly different parameters on the config we have that is closest to yours -- especially the timeout on port 8009.  Since IIS and Tomcat are on the same server on our machine, we don't expect long times for connections between the two.

server.xml:
<Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
               port="8009" minProcessors="5" maxProcessors="75"
               enableLookups="true" redirectPort="8443"
               acceptCount="10" debug="0" connectionTimeout="0"
               useURIValidationHack="false"
               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

In your workers.properties file, we don't use the ps parameter.  It's not in the doc:
http://tomcat.apache.org/connectors-doc/reference/workers.html
so I assume that it's ignored.

We do specify load-balancing, but there's only a single Tomcat running in that config, so I don't think it makes a difference.

We set the following values in workers.properties:
worker.ajp13w.connection_pool_size=10
worker.ajp13w.connection_pool_minsize=5
worker.ajp13w.connection_pool_timeout=30

and they don't break, but, like cachesize, I'm not sure we have the configuration to take advantage of these.

It's a little odd that you haven't upgraded your release of Java to 1.5 or 1.6, but it seems likely that that is not causing your problem here.
ASKER CERTIFIED SOLUTION
Avatar of lloyd142
lloyd142
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial