jmayer

Fine Tuning Tomcat for better performance

Discussion created by jmayer Champion on Mar 9, 2016
Latest reply on May 10, 2017 by jmayer

Dear all,

 

I starting this tread as proposed by Kyle for us to share our recommendation and experience on troubleshooting/fine tuning Tomcat for performance and eventually crash issue as an essential component of the application.

The idea is to not come too much in details and technical but keep it simple for everyone to benefit.

 

There is also a idea open hereIIS web server available for all SDM functionality. to move functionality from Tomcat to IIS to reduce that dependency but may you prefer continue to use Tomcat and until then I listed some bullet point already below.

 

The order of displaying the information below is intentional and you must start from the top at your first step and fall down to the end may this be needed.

 

Heap Memory

 

Out of the box configuration the heap memory to be consumed by tomcat in set relatively low and you may want to increase base on your need and size of system RAM.

This settings can be modified in the nx.env and will require a restart of the tomcat container

 

@NX_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=false -Xms64M -Xmx1024M

 

the -Xms switch determine the minimum memory size used at the started of the container

the -Xmx switch determine the maximum size that can be used by the container.

 

I often recommend to put the size of the -Xmx to 50% of you available RAM but if you run multiple application on that server you may want to go to a lower number.

You can configure those parameters for each of your tomcat container (REST, SA, Visualizer) but the total of those must not exceed more that 60% of your total system memory available to avoid impacting others components of your system.

 

If you have enough memory available, you can set the minimum and maximum heap to the same size to avoid garbage collection to happen too frequently. Garbage collection is an intensive consumer of CPU resource and much you can avoid it better it will be.

Please consider that this is a costly memory process as those memory will be reserve to Tomcat and can't be used by others application. Then size your RAM accordingly or try to compromise the ratio between the Xms and XmX that better suite your system

 

The example below will allocate and reserve 2gb of memory and prevent garbage collection until then

 

@NX_JAVA_OPTIONS=-Djava.net.preferIPv4Stack=false -Xms2048M -Xmx2048M

 

 

Note that this is just example and you need to fine tune to suit your needs.

still need to write here some steps to determine the size according to consumption

 

Threads

 

Thread settings are defined as part of your HTTP connector in your ./bopcfg/www/CATALINA_BASE/\conf /server.xml

Tread determine the number of "action" that Tomcat can perform in parallel for this connector. When the maximum number of thread is reached then the pending action have to wait for another to terminate.

 

minSpareThreads determine the number on thread to be created at startup

maxThreads determine the maximum number of Thread that the connector will handle simultaneously

acceptCount determine the number or request that will be queued if the maxThreads  number is reached before the connector simply refuse the connection

 

 

Note that the reach of the max thread may be due to the application not releasing them  because for example database queries are returned to slow. Then prior to increase this value you may want to check if the problem is not residing there vs. Tomcat. Increasing this number is consuming an important amount of the memory that we defined above.

There is generally no reason to increase those settings if you don't receive specific errors about this in your Tomcat log.

I will not recommend to go over 500 in any case

 

<Connector SSLEnabled="true" clientAuth="false" keystoreFile="E:\SSL\.keystore.pfx" keystorePass="password"  maxThreads="250" minSpareThreads="10" port="443" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS" sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2">

 

 

AJP Connector

This connector like the HTTP is configured in your ./bopcfg/www/CATALINA_BASE/\conf /server.xml

This connector is only needed if you use Tomcat in combination with Apache. if this is not the case you can disable this connector to save some resource by commenting it out

<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->

 

to continue here

 

Hope this help

 

/J

Outcomes