O'Reilly logo

Tomcat: The Definitive Guide, 2nd Edition by Ian F. Darwin, Jason Brittain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When Tomcat Won't Shut Down

As with any program that runs code and fields requests, there are times when Tomcat will not shutdown properly. For example, you issue a shutdown command, and regardless of whether the shutdown request seems to complete successfully, you notice that the Tomcat process is still running. Another common problem is that the Tomcat instance within the JVM stops responding to requests. Sometimes this is a problem with Tomcat, whereas in other cases you may just need to give Tomcat plenty of time to shutdown.

How long is a reasonable amount of time to wait for the JVM process to exit? This depends on many factors:

Your service goals

How long are you willing to wait, and how hard are you trying to make sure that all requests are completed gracefully?

The speed of your hardware

How fast is your CPU? Something you may want to measure: with no requests being handled, how long does it take for your server computer to bring down your web application, shut down Tomcat, and exit the JVM process? If doing that takes 10 seconds, you should expect Tomcat to take longer than 10 seconds to shut down all the way when it is in the middle of serving requests.

The longest request cycle in your web application(s)

If you have many long-running requests occurring simultaneously, it may take some time to shut down all of those request threads.

The number of concurrent requests at shutdown time

Each request usually uses one Thread object in the JVM. As lightweight as Threads are in comparison ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required