Performance Tuning in the Tomcat Server

Performance tuning of an Apache Tomcat Server isof your server's hardware.  If the maxThreads
considered a bit of a black art and something thatattribute is set too high, Tomcat startup time will
only an experienced Tomcat admin shouldincrease, and can slow down your server during peak
undertake.  While expertise with Tomcat and bestload periods trying to run a high number of request
practices for its implementation/management isthreads concurrently.
important, there are some basic tuning approaches 
you can employ that will provide significant benefits- Additional Connector attribute settings:
for little effort.  This article covers those* compression: Toggle between "on" and "off" to
approaches.determine which setting is best for your webapp.
 * compressableMimeTypes: If you enable
Spend some time understanding the installation ofcompression, set this attribute to show Tomcat
Tomcat, the web site's traffic level, and the webwhat you want it to compress.  Try something like
applications that it runs.  In general Tomcat performs"text/html,text/xml,text/javascript,text/css,text
better when you:plain".
  
- Start the JVM with its initial heap tomcat memoryOther important factors in performance tuning include:
size (the -Xms switch) set to the maximum memory- HTTP caching headers: Enabling the user's web
size.  Using the maximum setting, the JVM neverbrowser to cache the static content of your
needs to resize and reallocate the heap memorywebapps can greatly increase the user's perceived
while trying to serve requests.performance.  It is important to set the right set of
 response headers and their values when Tomcat
- Start the tomcat JVM with a higher heap memoryserves the webapp's static files. Proxying all requests
maximum using the -Xmx switch.  The higher thisto Tomcat from Apache HTTPD is not advised for
setting, the more memory is available, allowing themaximum Tomcat performance as that configuration
server a higher percentage of its CPU time to servemay cause a loss of about half of the Tomcat's
web requests.  If your webapp runs on dedicatedperformance.
server hardware, give the JVM as much of the 
machine's physical memory as reasonably possible.  If- HTTPS is slower than HTTP.  Bringing the Tomcat
it is running on shared or virtual hardware, hook up aserver geographically closer to the users may help
console (such as Tcat Server console) to see howreduce request times.
much memory your webapp uses under high load 
circumstances and adjust the maximum heap size- Many webapps use a relational database, making
accordingly.the database connection settings very important. 
 Adjust the maxActive, maxIdle, and maxWait
- Tweak the Connector (web server) thread poolattributes where you define your database
settings for your web request load based on yourconnection.
peak traffic patterns. If the maxThreads attribute is 
set too low, you may not have enough threads toIf using the AJP Connector, set the attribute
handle all of the requests causing requests to sit idlerequest.registerRequests="false" to stop logging
until another request thread is freed up to handletomcat JMX stats for the requests of the connector,
them, and Tomcat will be unable to take advantageto make performance steadier during traffic spikes.