title: Slow tomcat response and how to solve it
body: <p>Client sends the request to our system and it shows slow response. The client sees for example 9sec for one request. We have nginx -- tomcat8 -- our servlet.
  Nginx shows the same slow response from tomcat. But I created the Filter around servlet and added logging in filter and servlet. And java logging shows that response is 0.6 sec. The response is very simple just 200 code with couple headers and that's all. I checked GC logs and there's nothing special at this time.</p>
  
  <p>So now I don't understand what can take remaining 8 sec. It seems something inside tomcat but how to understand and monitor it?</p>
  
  <p>Env: JDK 8, Tomcat 8, Linux Debian Jessie.</p>
  
  <p>Java Run Params:</p>
  
  <pre><code>    echo 'JAVA_OPTS="$JAVA_OPTS -Xmx10500m -Xms10500m"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/log/tomcat8/garbagecollector.log"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+PrintPromotionFailure"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8999"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:MaxPermSize=128m"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+UseCodeCacheFlushing"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+CMSParallelRemarkEnabled"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+CMSScavengeBeforeRemark"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:MinHeapFreeRatio=50"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=80"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=30000"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:MaxNewSize=2512m -XX:NewSize=2512m -XX:+UseParNewGC"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=14"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:MaxTenuringThreshold=1"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:-OmitStackTraceInFastThrow"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'JAVA_OPTS="$JAVA_OPTS -Dsun.net.inetaddr.ttl=60"' &gt;&gt; $TOMCAT_CONFIG
      echo 'JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/tomcat8/OOME.hprof"' &gt;&gt; $TOMCAT_CONFIG
  
      echo 'ulimit -n 65535' &gt;&gt; $TOMCAT_CONFIG
  </code></pre>