Optimize TOMCAT: Increase TOMCAT6 response pool

Source: Internet
Author: User
Tags install openssl openssl sendfile apache tomcat
Find the Server.xml file in the Conf directory under the TOMCAT6 installation directory for editing
Shielding Tomcat default connector:
<!–connector port= "8080″protocol=" Http/1.1″
Connectiontimeout= "20000″
Redirectport= "8443″/-->
To create a connector with high threads:
<connector executor= "Tomcatthreadpool" port= "8080" protocol= "http/1.1" maxhttpheadersize= "8192" Usebodyencodingforuri= "true" maxthreads= "1000" enablelookups= "false" redirectport= "8443" acceptcount= "100" Compression= "On" "compressionminsize=" 2048 "compressablemimetype=" text/html,text/xml,text/javascript,text/css, Text/plain "connectiontimeout=" 20000 "disableuploadtimeout= true" uriencoding= "UTF-8"/>
<connector port= "8080″
Executor= "Tomcatthreadpool" protocol= "http/1.1" redirectport= "8443″maxhttpheadersize=" 8192″usebodyencodingforuri = "true" minprocessors= "100″maxprocessors=" 5000″maxthreads= "5000″minsparethreads=" 1000″maxsparethreads= "4000″" Enablelookups= "false" acceptcount= "100″compression=" on "compressionminsize=" 2048″compressablemimetype= "text/html , Text/xml,text/javascript,text/css,text/plain "connectiontimeout=" 60000″keepalivetimeout= "15000" maxkeepaliverequests= "1" disableuploadtimeout= "true" debug= "0″uriencoding=" utf-8″/>
(Note: Add the response thread number control, add the compression transfer mode, adjust timeout settings, shielding debug mode)
Parameter description:
connectiontimeout-Network connection timeout, in milliseconds. A setting of 0 means never time out, and this setting is hidden. Typically, it can be set to 30000 milliseconds.
KeepAliveTimeout-long connection maximum retention time (ms). Here is 15 seconds.
maxkeepaliverequests-Maximum number of long connections (1 is disabled,-1 indicates unlimited number, default 100). The general setting is between 100~200) the maximum number of HTTP requests that can was held in the pipeline until the connection was closed by the Server. Setting this attribute to 1 disables http/1.0 keep-alive, as as the http/1.1 keep-alive and pipelining. Setting This to-1 allows a unlimited number of pipelined or keep-alive HTTP requests. If not specified, the This attribute was set to 100.
The maximum amount of Maxhttpheadersize-http request header information is not processed in excess of this length. General 8K.
uriencoding-Specifies the URL encoding format for the Tomcat container.
Acceptcount-Specifies the number of requests that can be placed in the processing queue when all available processing requests are used, and requests that exceed this number are not processed and default to 10. Defines the maximum queue length for incoming connection requests while all possible request processing threads. Any requests received when the ' queue is full are refused. The default value is 10.
Disableuploadtimeout-whether to use timeout mechanism when uploading
enablelookups-Checks whether the domain name is reversed, and evaluates to: TRUE or false. To improve processing power, set to False
buffersize-defines the size (in bytes) of the ' buffer to be ' provided for input streams created from this connector. By default, buffers of 2048 bytes are provided.
maxsparethreads– Maximum number of idle connections, and once the thread is created exceeds this value, tomcat closes the socket thread that is no longer needed the maximum number of unused request processing threads T Hat are allowed to exist until the thread pool starts stopping the unnecessary threads. The default value is 50.
MaxThreads-The maximum number of simultaneous connections, Tomcat uses threads to handle each request received. This value represents the maximum number of threads that Tomcat can create. The maximum number of request processing threads to is created by this Connector, which therefore determines the maximum n Umber of simultaneous requests can be handled. If not specified, the This attribute was set to 200.
Minsparethreads-Minimum number of idle threads, number of threads created when Tomcat initializes the count of request processing threads that are created time this Connector is the started. The connector'll also make sure it has specified number of idle processing threads. This attribute should is set to a value smaller than the set for MaxThreads. The default value is 4.
Minprocessors-The minimum number of idle connection threads to improve system processing performance with the default value of 10. (used in TOMCAT4)
Maxprocessors-The maximum number of connection threads, that is, the maximum number of requests that are processed concurrently, with a default value of 75. (used in TOMCAT4)
Note:
TOMCAT4 can be used to control the number of threads by modifying the values of Minprocessors and maxprocessors.
In tomcat5+ the following parameters are mainly adjusted
Maxthreads:tomcat uses threads to handle each request that is received. This value represents the maximum number of threads that Tomcat can create.
Acceptcount: Specifies the number of requests that can be placed in the processing queue when all available processing requests are used, and requests that exceed this number will not be processed.
Connnectiontimeout: Network connection timeout, in milliseconds. A setting of 0 means never time out, and this setting is hidden. Typically, it can be set to 30000 milliseconds.
Minsparethreads:tomcat the number of threads created when initializing.
Maxsparethreads: Once a thread is created that exceeds this value, tomcat closes the socket thread that is no longer needed. The configuration process for Tomcat APR
Tomcat can use APR to provide superior scalability and performance, and to better integrate local server technology. APR (Apache portable Runtime) is a highly portable library that is the core of the Apache HTTP Server 2.x. APR has many uses, including access to advanced IO features (such as Sendfile,epoll and OpenSSL), OS-level features (random number generation, System state, and so on), local process management (shared memory, NT pipelines, and UNIX sockets). These features enable Tomcat as a common front-end Web server to better integrate with other local web technologies, making Java more efficient as a high-performance WEB server platform rather than simply a background container.
In a product environment, especially when using Tomcat directly as a WEB server, you should use Tomcat Native to improve performance, and for detailed configuration and installation refer to the Tomcat documentation. If there is no APR technology, the following prompts appear when you start Tomcat:
Info: The APR based Apache Tomcat Native Library which allows optimal performance in production environments is not found On the Java.library.path:/usr/java/jdk1.6.0_06/jre/lib/i386/client:/usr/java/jdk1.6.0_06/jre/lib/i386:/usr/java/ Jdk1.6.0_06/jre/.. /lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib according to the official description needs:
* APR Library
* OpenSSL Libraries
OpenSSL can be installed using Yum install openssl-devel, Apr or download *.gz. Apr-1.3.2.tar.gz
Apr-util-1.3.2.tar.gz
Two can be found in http://archive.apache.org/dist/apr/. Tomcat-native-1.1.24-src.tar.gz
Can be found in the http://archive.apache.org/dist/tomcat/tomcat-connectors/native/directory. The following is the APR configuration process:
Install Apr
1. Tar zxvf apr-1.3.2.tar.gz
2. CD apr-1.3.2
3./configure
4. Make
5. Make install
Apr default installation in/USR/LOCAL/APR
Install Apr-util
1. Tar zxvf apr-util-1.3.2.tar.gz
2. CD apr-util-1.3.2
3./configure--WITH-APR=/USR/LOCAL/APR
4. Make
5. Make install installation tomcat-native

1. Tar zxvf tomcat-native.tar.gz
2. CD tomcat-native-1.1.24-src/jni/native
3./configure--WITH-APR=/USR/LOCAL/APR--with-java-home=/usr/java/jdk1.6.0_29
4. Make
5. Make install set APR's environment variable:
1. Vi/etc/profile
2. Add the following content
apr_home=/usr/local/apr/
Ld_library_path= $LD _library_path: $APR _home/lib
Export Ld_library_path
3. To make the configuration effective source/etc/profile to not affect other Tomcat configuration, we do not use the above set method, but directly in the Tomcat bin in the catalina.sh to add the following configuration:
Ld_library_path= $LD _library_path:/usr/local/apr/lib
Export Ld_library_path start Tomcat, look at the log, like the next line:
Info: APR Capabilities:ipv6 [true], sendfile [true], accept filters [FALSE], random [true]. -------------------------Configuration 1-----------------------
<connector port= "8080" redirectport= "8443"
maxthreads= "5000"
minsparethreads= "1000"
maxsparethreads= "4000"
Enablelookups= "false"
acceptcount= "3500"
Compression= "On"
Compressablem imetype= "Text/html,text/xml,text/javascript,text/css,text/plain"
Connectiontimeout= "60000"
debug= "0"
uriencoding= "UTF-8"/>--------------------recommended----Configuration 2---------------------
<connector port= "8081"
Executor= "Tomcatthreadpool" protocol= "http/1.1" redirectport= "6203"
Maxhttpheadersize= "8192" usebodyencodingforuri= "true"
minprocessors= "100"
maxprocessors= "5000"
maxthreads= "5000"
minsparethreads= "1000"
maxsparethreads= "4000"
Enablelookups= "false"
acceptcount= "100"
Compression= "On"
Compressionminsize= "2048"
Compressablemimetype= "Text/html,text/xml,text/javascript,text/css,text/plain"
Connectiontimeout= "60000"
keepalivetimeout= "15000"
maxkeepaliverequests= "1"
Disableuploadtimeout= "true"
debug= "0"
uriencoding= "UTF-8"/>
---------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.