Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My Tomcat 6.0.26 sometimes dies saying:

SEVERE: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status

... then Tomcat shuts down, and users can't access the webapp until I restart Tomcat manually.

Some of the threads indeed take a long time to execute, it is by-design, not a thread-gone-wild problem.

I know I could increase maxThreads, but that is not a viable solution, because the server might receive requests even more requests.

QUESTION: Instead of dying, can I tell Tomcat to just drop requests when maxThreads is reached and the AJP/1.3 backlog is full?

Below is my server.xml in any case:

<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JasperListener" />
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" minSpareThreads="100"/>
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"
               enableLookups="false" useBodyEncodingForURI="true"
               backlog="150" maxThreads="150" executor="tomcatThreadPool"
               keepAliveTimeout="5000" connectionTimeout="300000" />
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="ecm1">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
    </Engine>
  </Service>
</Server>
share|improve this question
    
Are you sure Tomcat shuts down itself and doesn't get killed (out of memory)? –  faker Jul 2 '12 at 9:04
    
@faker: I see no message indicating a lack of memory. Usually when it is a memory problem I can see an OutOfMemory exception. The shutdown time is exactly after the maxThreads message appears, which leads me to think it is the cause. –  Nicolas Raoul Jul 2 '12 at 9:56

1 Answer 1

up vote 1 down vote accepted

Tomcat won't crash just because threads are maxed out. It queues up requests to the limit set in acceptCount and then refuses requests if that maxes out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.