Tuesday, July 17, 2012

Tomcat Performance Tunning

In order to handle scalability, webserver needs to be controlled by certain configuration.
In this post we wil take Tomcat as a web server and go through ceratin configurations so that It handle heavey requests.

  • Increase JVM heap memory
    JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8
    -server -Xms1024m -Xmx1024m
    -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m
    -XX:MaxPermSize=512m -XX:+DisableExplicitGC"
     
  • Resolve JRE memory leaks Tomcat server.xml contains
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"
     />
     
  • Thread pool setting
    <Connector port="8080" address="localhost"
    maxThreads="250" maxHttpHeaderSize="8192"
    emptySessionPath="true" protocol="HTTP/1.1"
    enableLookups="false" redirectPort="8181" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
     If the number of threads reaches much higher say more than 750 its better to 
    go for clustering. 
    Higher is the max threads more will be the application start up time.
    
    
  • Compression    : server.xml configuration
    <Connector port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8181" compression="500"
    compressableMimeType="text/html,text/xml,text/plain,application/octet-stream" />
     
  • Database performance tuning : Twiking maxIdle, maxActive, and maxWait...
  • Tomcat Native Library
  • Go for stateless application
  • Database connection pooling configuration :Set the max active connection,  connection waiting time out , Idle connection properly.

No comments:

Post a Comment