You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jesse Barnum <je...@gmail.com> on 2016/12/22 15:20:25 UTC

Shutting down contexts: Serial or parallel?

I am running multiple webapps on Tomcat 7, and I’ve noticed that when shutting down Tomcat, the ContextListeners are called in serial, instead of in parallel. Some of these webapps take 5-15 seconds to run various shutdown procedures. This can exceed the timeout period for shutting down, which means that the orderly shutdown process can be skipped when there are more then 5 or 6 webapps.

I know one solution for this problem is to increase the shutdown timeout. However, is there a good reason to shutdown contexts in serial, rather than in parallel? That would solve the problem and prevent lengthy shutdowns, which in turn would reduce downtime for maintenance.

—Jesse Barnum, President, 360Works
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Shutting down contexts: Serial or parallel?

Posted by Jesse Barnum <je...@gmail.com>.
> On Dec 23, 2016, at 3:05 AM, Mark Thomas <ma...@apache.org> wrote:
> 
>> I have 13 web apps installed, and I changed the startStopThreads to 15.
>> It did not seem to make the application launch any faster. Looking at
>> the startup messages like this:
> 
> startStopThreads only applies to the immediately nested component. So using the setting on the Engine will try to start your one host in parallel. Not helpful. Try moving that setting to the Host.
> 
> Mark

I did that and I can now see them starting in parallel. Thank you.

—Jesse Barnum, President, 360Works

Re: Shutting down contexts: Serial or parallel?

Posted by Mark Thomas <ma...@apache.org>.
On 23 December 2016 02:13:56 GMT+00:00, Jesse Barnum <je...@gmail.com> wrote:
>
>> On Dec 22, 2016, at 11:31 AM, Christopher Schultz
><ch...@christopherschultz.net> wrote:
>> 
>> There's 7.0.73 but it shouldn't make too much of a difference. I just
>> wanted to make sure you weren't running 7.0.1-RC or some weird thing
>> that's ages old.
>> 
>> In Tomcat 7 there is a setting on the <Engine> component called
>> "startStopThreads"[1]. The default is 1 which means that a single
>> thread will be used to start/stop applications during
>> startup/shutdown, so the behavior you are seeing is expected.
>> 
>> If you want to use more threads, then you'll need to add/adjust that
>> setting. Something like this:
>> 
>> server.xml
>> - ----------
>> 
>> ...
>>   <Engine name="Catalina" defaultHost="localhost"
>>      startStopThreads="6">
>>   ...
>>   </Engine>
>> ...
>> 
>> That setting should use 6 threads and start/stop all your
>applications
>> simultaneously.
>> 
>> - -chris
>
>I have 13 web apps installed, and I changed the startStopThreads to 15.
>It did not seem to make the application launch any faster. Looking at
>the startup messages like this:

startStopThreads only applies to the immediately nested component. So using the setting on the Engine will try to start your one host in parallel.  Not helpful. Try moving that setting to the Host.

Mark

>
>Dec 23, 2016 1:59:28 AM org.apache.catalina.core.StandardService
>startInternal
>INFO: Starting service Catalina
>
>Dec 23, 2016 1:59:55 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/PaypalCallbacks.xml has finished in
>26,514 ms
>
>Dec 23, 2016 2:00:00 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/cyber.xml has finished in 4,973 ms
>
>Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/ROOT.xml has finished in 3,514 ms
>
>Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/manager.xml has finished in 188 ms
>
>Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/host-manager.xml has finished in 186 ms
>
>Dec 23, 2016 2:00:16 AM org.apache.catalina.startup.HostConfig
>deployDescriptor
>INFO: Deployment of configuration descriptor
>/etc/tomcat7/Catalina/localhost/360Store.xml has finished in 12,367 ms
>
><etc\u2026>
>
>It seems that the clock time of each message is equal to the sum of all
>of the startup times, which is not what I would expect if it were using
>multiple threads.
>
>Looking at the documentation for this attribute close, I see this:
>
>> The number of threads this Engine will use to start child Host
><https://tomcat.apache.org/tomcat-7.0-doc/config/host.html> elements in
>parallel
>
>Do I need to configure one webapp per Host element in order to utilize
>multiple threads? I just have a single Host element.
>
>\u2014Jesse Barnum, President, 360Works



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Shutting down contexts: Serial or parallel?

Posted by Jesse Barnum <je...@gmail.com>.
> On Dec 22, 2016, at 11:31 AM, Christopher Schultz <ch...@christopherschultz.net> wrote:
> 
> There's 7.0.73 but it shouldn't make too much of a difference. I just
> wanted to make sure you weren't running 7.0.1-RC or some weird thing
> that's ages old.
> 
> In Tomcat 7 there is a setting on the <Engine> component called
> "startStopThreads"[1]. The default is 1 which means that a single
> thread will be used to start/stop applications during
> startup/shutdown, so the behavior you are seeing is expected.
> 
> If you want to use more threads, then you'll need to add/adjust that
> setting. Something like this:
> 
> server.xml
> - ----------
> 
> ...
>   <Engine name="Catalina" defaultHost="localhost"
>      startStopThreads="6">
>   ...
>   </Engine>
> ...
> 
> That setting should use 6 threads and start/stop all your applications
> simultaneously.
> 
> - -chris

I have 13 web apps installed, and I changed the startStopThreads to 15. It did not seem to make the application launch any faster. Looking at the startup messages like this:

Dec 23, 2016 1:59:28 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina

Dec 23, 2016 1:59:55 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/PaypalCallbacks.xml has finished in 26,514 ms

Dec 23, 2016 2:00:00 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/cyber.xml has finished in 4,973 ms

Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/ROOT.xml has finished in 3,514 ms

Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/manager.xml has finished in 188 ms

Dec 23, 2016 2:00:03 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/host-manager.xml has finished in 186 ms

Dec 23, 2016 2:00:16 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deployment of configuration descriptor /etc/tomcat7/Catalina/localhost/360Store.xml has finished in 12,367 ms

<etc…>

It seems that the clock time of each message is equal to the sum of all of the startup times, which is not what I would expect if it were using multiple threads.

Looking at the documentation for this attribute close, I see this:

> The number of threads this Engine will use to start child Host <https://tomcat.apache.org/tomcat-7.0-doc/config/host.html> elements in parallel

Do I need to configure one webapp per Host element in order to utilize multiple threads? I just have a single Host element.

—Jesse Barnum, President, 360Works

Re: Shutting down contexts: Serial or parallel?

Posted by Jesse Barnum <je...@gmail.com>.
> On Dec 22, 2016, at 11:31 AM, Christopher Schultz <ch...@christopherschultz.net> wrote:
> 
> In Tomcat 7 there is a setting on the <Engine> component called
> "startStopThreads"[1]. The default is 1 which means that a single
> thread will be used to start/stop applications during
> startup/shutdown, so the behavior you are seeing is expected.
> 
> If you want to use more threads, then you'll need to add/adjust that
> setting. Something like this:
> 
> server.xml
> - ----------
> 
> ...
>   <Engine name="Catalina" defaultHost="localhost"
>      startStopThreads="6">
>   ...
>   </Engine>
> ...
> 
> That setting should use 6 threads and start/stop all your applications
> simultaneously.

Perfect, that’s just what I needed! Thank you!

—Jesse Barnum, President, 360Works

Re: Shutting down contexts: Serial or parallel?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jesse,

On 12/22/16 10:41 AM, Jesse Barnum wrote:
> 
>> On Dec 22, 2016, at 10:39 AM, Christopher Schultz
>> <ch...@christopherschultz.net> wrote:
>> 
>> On 12/22/16 10:20 AM, Jesse Barnum wrote:
>>> I am running multiple webapps on Tomcat 7, and I\u2019ve noticed
>>> that when shutting down Tomcat, the ContextListeners are called
>>> in serial, instead of in parallel. Some of these webapps take
>>> 5-15 seconds to run various shutdown procedures. This can
>>> exceed the timeout period for shutting down, which means that
>>> the orderly shutdown process can be skipped when there are more
>>> then 5 or 6 webapps.
>>> 
>>> I know one solution for this problem is to increase the
>>> shutdown timeout. However, is there a good reason to shutdown
>>> contexts in serial, rather than in parallel? That would solve
>>> the problem and prevent lengthy shutdowns, which in turn would
>>> reduce downtime for maintenance.
>> 
>> Which exact version of Tomcat 7 are you using?
> 
> Apache Tomcat/7.0.65
> 
> Has this changed in a newer version? I\u2019m happy to update if that is
> the case.

There's 7.0.73 but it shouldn't make too much of a difference. I just
wanted to make sure you weren't running 7.0.1-RC or some weird thing
that's ages old.

In Tomcat 7 there is a setting on the <Engine> component called
"startStopThreads"[1]. The default is 1 which means that a single
thread will be used to start/stop applications during
startup/shutdown, so the behavior you are seeing is expected.

If you want to use more threads, then you'll need to add/adjust that
setting. Something like this:

server.xml
- ----------

 ...
   <Engine name="Catalina" defaultHost="localhost"
      startStopThreads="6">
   ...
   </Engine>
 ...

That setting should use 6 threads and start/stop all your applications
simultaneously.

- -chris

[1]
http://tomcat.apache.org/tomcat-7.0-doc/config/engine.html#Common_Attrib
utes
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYW//fAAoJEBzwKT+lPKRYtD8P/3J0c7Ky/CXfg/Iloc8XXNUX
6lYwXwq0eIjjsqjHzScIFbdITwe2wA+7Hnf1YPW75KUKXQlz2aZXeFPULjNEnD0b
IkShEYdHh6uJa/Zs0yOzNMlIvUYHynoG6kISl+UQdUKk6L2fCOEzqeA3ZzGg+W2v
V5Pa5ntDaQUynrSYmvYZ4v5jKkyrkhCppdnCA9FPTm+WEBEy7ApauiL2/Pu398cG
LDThVjK8PhpFZg5WQv7w+GPeZec8JjjBsWPd1PNocG+SymlCw+O0qAtWxb0xXRsB
xwkSD30XmKL7EJfqxyC4Np20rHxsNUqAxc7Qeq/hn2KQQLPkvadd41XjHVf6gWZo
hYDQyUKDpsk5WD5Lh9SHFlTQwO3iAOvOjjnQzJG+bCZl0QXcfWxm2bYWFfJHQB6s
VXeJRV8LwMAgJV87jYAosKLGizl8mx4URDFtrfImrx9PdXjpUyNVDYU+csofGVN/
axG8k8DeFVp2qOPeuJQ/Ad+30dO8Oi46voGPbXZKJV4nPRNN5RuSbFpXDdtfz34W
gUXE6IFi/veMN4nP1+dqKisBWPhttMwXDnvK/g3S43UE2dlVA7y2lS1xmjzY3XDP
GC+e/TUzRFhKG/XjeuiELWyDpTUqzHOGH8MWOKbjguNKjqyhnZdCfvt6OkK4Id+I
Z81o0uuQXlECeKcHZIdR
=bv8S
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Shutting down contexts: Serial or parallel?

Posted by Jesse Barnum <je...@gmail.com>.
> On Dec 22, 2016, at 10:39 AM, Christopher Schultz <ch...@christopherschultz.net> wrote:
> 
> On 12/22/16 10:20 AM, Jesse Barnum wrote:
>> I am running multiple webapps on Tomcat 7, and I’ve noticed that
>> when shutting down Tomcat, the ContextListeners are called in
>> serial, instead of in parallel. Some of these webapps take 5-15
>> seconds to run various shutdown procedures. This can exceed the
>> timeout period for shutting down, which means that the orderly
>> shutdown process can be skipped when there are more then 5 or 6
>> webapps.
>> 
>> I know one solution for this problem is to increase the shutdown 
>> timeout. However, is there a good reason to shutdown contexts in 
>> serial, rather than in parallel? That would solve the problem and 
>> prevent lengthy shutdowns, which in turn would reduce downtime for 
>> maintenance.
> 
> Which exact version of Tomcat 7 are you using?

Apache Tomcat/7.0.65

Has this changed in a newer version? I’m happy to update if that is the case.

—Jesse Barnum, President, 360Works

Re: Shutting down contexts: Serial or parallel?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Jesse,

On 12/22/16 10:20 AM, Jesse Barnum wrote:
> I am running multiple webapps on Tomcat 7, and I\u2019ve noticed that
> when shutting down Tomcat, the ContextListeners are called in
> serial, instead of in parallel. Some of these webapps take 5-15
> seconds to run various shutdown procedures. This can exceed the
> timeout period for shutting down, which means that the orderly
> shutdown process can be skipped when there are more then 5 or 6
> webapps.
> 
> I know one solution for this problem is to increase the shutdown 
> timeout. However, is there a good reason to shutdown contexts in 
> serial, rather than in parallel? That would solve the problem and 
> prevent lengthy shutdowns, which in turn would reduce downtime for 
> maintenance.

Which exact version of Tomcat 7 are you using?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYW/PIAAoJEBzwKT+lPKRYYtoQAJE2+S2ZrPG6hhiM/DdhpU6m
Gw2p7NBs6Q3W+6TC8S0VlvdOcbKpE1qDK4EGOS+SoPpJuwPU81O9zzC4uQyoRAxX
0UnL1kreDCwOR3zYFYx2uCoMxJ7Ca4pbhb9CEm3leNkfLGbymreRCwmGJaZfX8vY
DoH9izq2kE7QMTnp4jphP4Yl2JcJSacssNhy8bAscxYFqNP9OtXfUzUgd8o5zEUx
TyGatuKqToMCC6x8ke4uyw07iqdtmdvO9ZDG1Kv6EblNPdbY8M30NW6C1AeiTreU
hoe9sbWvd8KSblV8uJLgNFm0hDYGj9Lu3+ovYRrbF13MklVBoSIV4mwDbHmmcG+G
DxXmrhuHd0pemRMYMolPzUeDoBCcR4IVev/mFdUOWQesSByBNLXR3JJYiyxKHcEE
l3U3EkujVlqOq5OHI0WUMtlGDCgkQk2PpjXwimfaZRhMKGCsoYU7jVtbpCPktXd5
YfzqzBmQ5jRW8RaxFhNXGAK0b4kqVAnCNQprRP7QFZrR2As0XCrXztl0vrOtFpM5
1oEshyVAyGMm3t68N4pTcpnbcexsJNZIqR6za65xqOU5ILI5TZzOEKu6xFP2PtBy
x49RuoDXa+tKfrYmm8RMBfJQM63BimIhtJLBPF+UXXPsPCLpIVJyPZNF/bjNLhTs
ONRxYzBM6G/1VKiPzPMI
=pJUk
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org