tomcat parameter optimization

        Recently, due to the performance problems of the project application, the parameters of the application container tomcat have been optimized.

        tomcat version 8.0.23

First, configure a long connection from nginx to tomcat

nginx:

 

upstream tomcat_server{
      server xx.xx.xx.xx:8080
      keepalive 400;
}

..............

location /XXXXX {
       proxy_pass   http://tomcat_server/XXXXX/;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Cookie $http_cookie;
       proxy_http_version 1.1;
       proxy_set_header Connection "";
}

 

tomcat:

 

<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
               connectionTimeout="15000"
               maxThreads="600"
               acceptCount="100"
               executor="tomcatThreadPool"
               acceptorThreadCount="4"
               keepAliveTimeout="-1"
               maxKeepAliveRequests="-1"
               maxPostSize="0"
               enableLookups="flase"
               redirectPort="8443" />

 

 

Then, increase the connection pool configuration

tomcat:

 

<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
                maxThreads="600"
                minSpareThreads="200"
                prestartminSpareThreads="true"
                maxQueueSize="100"/>


 <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
               connectionTimeout="10000"
               acceptCount="100"
               executor="tomcatThreadPool"
               acceptorThreadCount="4"
               keepAliveTimeout="-1"
               maxKeepAliveRequests="-1"
               maxPostSize="0"
               enableLookups="flase"
               redirectPort="8443" />

 

 

The protocol here can also use nio2

     protocol="org.apache.coyote.http11.Http11Nio2Protocol" 

 

Finally, apr is also installed

Apr installation steps:

redhat6.1

1) Replace yum source  wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

     Change $ releasever in CentOS6-Base-163.repo to 6

 

2) Execute the following command

      yum clean all 

      yum makecache

      yum install apr-devel

      yum install openssl-devel

      yum install gcc

      yum install make

      cd /opt/tomcat/apache-tomcat-8.0.23/bin/tomcat-native-1.1.33-src/jni/native

      ./configure --with-apr=/usr/bin/apr-1-config

      make

      make install

 

3) Configure environment variables

      Add in /etc/profile

       export LD_LIBRARY_PATH = /usr/local/apr/lib

       export LD_RUN_PATH=/usr/local/apr/lib

 

ubuntu16.04

1) Update a download source

    apt-get clean

    apt-get update

    apt-get upgrade

 

2) apt-get install libapr1 libapr1-dev  libaprutil1-dev

 

3) Configure environment variables

      Add in ~/.bashrc

       export LD_LIBRARY_PATH = /usr/local/apr/lib

       export LD_RUN_PATH=/usr/local/apr/lib

 

 Enable apr's tomcat configuration

<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
               connectionTimeout="10000"
               acceptCount="100"
               executor="tomcatThreadPool"              
               keepAliveTimeout="-1"
               maxKeepAliveRequests="-1"
               maxPostSize="0"
               enableLookups="flase"
               redirectPort="8443" />

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326781745&siteId=291194637