• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1460
  • Last Modified:

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
  • 5
  • 5
1 Solution
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:

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:

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:

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?
lloyd142Author Commented:
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:
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

lloyd142Author Commented:
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.
lloyd142Author Commented:
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 failed (errno=61)
[Sat Nov 24 12:52:05.093 2007] [3324:5424] [info] jk_ajp_common.c (891): Failed opening socket to ( (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
[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.
lloyd142Author Commented:
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
workers.java_home=D:\Program Files\j2sdk1.4.2_02
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" />

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.

<Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
               port="8009" minProcessors="5" maxProcessors="75"
               enableLookups="true" redirectPort="8443"
               acceptCount="10" debug="0" connectionTimeout="0"

In your workers.properties file, we don't use the ps parameter.  It's not in the doc:
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:

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.
lloyd142Author Commented:
Having tinkered with all the settings suggested the solution came from somewhere else. I updated the database driver from an old non-production one to an up to date SQL Server driver. This seemed to stop the IIS server from crashing. It has been suggested that the previous database driver was crashing which in turn caused IIS or Tomcat to crash. Thanks for all the comments that have been made on this issue
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now