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" />
    <Resource name="UserDatabase" auth="Container"
              description="User database that can be updated and saved"
              pathname="conf/tomcat-users.xml" />
  <Service name="Catalina">
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" minSpareThreads="100"/>
    <Connector port="8080" protocol="HTTP/1.1"
               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"
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
  • 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. Jul 2 '12 at 9:56

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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