Startup and Deployment Time

The following tuning could dramatically reduce tomcat startup and WebApp deployment times.

Deploy Apps in Parallel

Apps in Tomcat are deployed sequntally by default, since the deployment is managed by a thread pool named Start-Stop threads. The number of threads in this pool is 1 by default.

The recommended settings is to be the same number of as the number of processors on the host server, to ensure actual parallelization.

To change the number of threads of this pool:

In TOMCAT_HOME/conf/server.xml Add startStopThreads="0" to <Host tag, this will create a thread per processor to handle parallel deployments, by default the value is 1 thread.

The Host tag should looks for something like this.

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true" startStopThreads="0">

Jars Scanning

By default, Tomcat scans every class in every jar for annotations, web-fragments, and TLD’s, this could increase the startup and deployment times. There are many options to workaround this behavior, the most convenient (in my opinion) is as follows:

In TOMCAT_HOME/conf/catalina.properties:

  1. Add *.jar to tomcat.util.scan.StandardJarScanFilter.jarsToSkip property, this will make Tomcat ignore all the jars by default from initial scanning.

  2. Set the needed jars to be scanned in tomcat.util.scan.StandardJarScanFilter.jarsToScan property, in our case, we to ensure that we just scan the following jars. j-framework-web*.jar, primefaces*.jar,jsf*.jar, jersey-container*.jar, spring-web*.jar, spring-security-web*.jar

The catalina.properties should looks like this:

tomcat.util.scan.StandardJarScanFilter.jarsToSkip=*.jar

tomcat.util.scan.StandardJarScanFilter.jarsToScan=\
j-framework-web*.jar, \
primefaces*.jar,\
jsf*.jar, \
jersey-container*.jar, \
jar,spring-web*.jar, \
spring-security-web*.jar