Tomcat connector Elements Common configuration (maximum number of connections, etc.)

Source: Internet
Author: User

There are similar server.xml in Tomcat:

<connector port="8080"Protocol="http/1.1"connectiontimeout="20000"redirectport="8443"maxsparethreads=" -"maxthreads=" +"minsparethreads=" -"Acceptcount=" +"maxprocessors=" +"uriencoding="GBK"Usebodyencodingforuri="true"/>

The configuration, where:

acceptcount= "1000" acceptable maximum number of connections

maxprocessors= "1000" Maximum number of active threads

port= "8080" service port

Protocol= "http/1.1" service agreement

connectiontimeout= "20000" time-out unit is MS

redirectport= the "8443" redirect Port requires secure communication, the client request is forwarded to the Redirectport port of SSL

Maxthreads:tomcat the maximum number of threads that can be created, each thread processes a request; MaxThreads determines the maximum thread threshold for Tomcat, which needs to be set to a larger

Minsparethreads: The minimum number of standby threads, the number of threads initialized at Tomcat startup;

Maxsparethreads: Maximum number of spare threads, once the thread is created that exceeds this value, Tomcat shuts down the socket thread that is no longer needed;

Uriencoding= "GBK" to set the Tomcat default transcoding format

View $tomcat_home/webapps/tomcat-docs/config/http.html This documentation, with the following instructions: uriencoding:this Specifies the character encoding Used to decode the URI bytes, after%xx decoding the URL. If not specified, iso-8859-1 'll be used. In other words, if uriencoding is not set, tomcat defaults to URL decoding by iso-8859-1, Iso-8859-1 does not include Chinese characters, so the Chinese characters must not be parsed correctly.

Reprint someone else's blog:

one. Tomcat Connection Pool configuration Tomcat wants to withstand large concurrency and must increase the number of connections, and the general Tomcat Connector can be modified as follows:

<ConnectorPort= "80"Protocol= "http/1.1"ConnectionTimeout= "60000"Redirectport= "8443"MaxThreads= "5000" Acceptcount= "= " Maxsparethreads= " Enablelookups=" false "  Compression=" on " Compressionminsize= "2048"  Compressablemimetype= "Text/html,text/xml,text/javascript,text/css,text/plain"  disableuploadtimeout< Span style= "color: #0000ff;" >= "true"  Uriencoding=" UTF-8 " />         

Some of the key parameters are:

connectiontimeout: The connection time-out, in milliseconds. For high concurrency the real-time requirements are not high can be made appropriate increase this value

maxthreads: Maximum number of concurrent connections

Acceptcount: The number of queued lines that can be accepted after the maximum number of connections

minsparethreads: The number of threads that are created by default when Tomcat is initialized, and the minimum number that is incremented at a later time when the thread increases

maxsparethreads: This parameter identifies that if the number of threads created exceeds this value, Tomcat closes the inactive thread

enablelookups: turn off DNS queries in the implementation, we find that using this configuration, the number of connections is difficult to descend after, resulting in the CPU has been maintained at a relatively high level.
Later we switched to a connection method, using the thread pool, first defining a executor:

<name= "Tomcatthreadpool"         nameprefix= "tomcatthreadpool-" maxthreads= "1000" maxidletime= "300000" minsparethreads= "$"/>        


The meaning of the parameter is the same as above
Use this connection pool as defined in connector:

<Executor= "Tomcatthreadpool"           port= "20003" protocol= "http/1.1" acceptcount = "Minprocessors" = "+" = "redirectport" =   "8443"/>   

Minprocessors,maxprocessors is similar to the minsparethreads,maxthreads above. After the connection pool is used, the number of connections is increased, and if there is no request for a period of time, the number of connections drops quickly, the CPU consumption is reduced effectively, and the processing power is improved.

How do I see the current number of Tomcat connections?

Assume that 2 Tomcat instances are open on the server, listening to 8040 and 8050 ports, respectively

Netstat-na | grep estab | grep 8040 | Wc-l

Netstat-na | grep estab | grep 8050 | Wc-l

The sum of the two is the number of connections for all Tomcat

Tomcat connector Elements Common configuration (maximum number of connections, etc.)

Related Article

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.