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

Source: Internet
Author: User
TOMCAT Connector Dollar

There are similar in the server.xml of Tomcat:

[HTML] view plain copy <span style= "font-size:14px" ><connector port= "8080" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443" maxsparethreads= "750" maxthreads= "1000" minsparethreads= "50" acceptcount= "1000" maxprocessors= "1000" uriencoding= "GBK" usebodyencodingforuri= "true"/></span> configuration, where:

Maximum number of connections acceptable to acceptcount= "1000"

maxprocessors= "1000" Maximum number of active threads

port= "8080" service port

Protocol= "http/1.1" service agreement

connectiontimeout= "20000" timeout unit is MS

redirectport= the "8443" redirect port requires secure communication, the customer request will be forwarded to the SSL Redirectport port

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

Minsparethreads: Minimum number of standby threads, number of initialized threads at tomcat startup;

Maxsparethreads: The maximum number of standby threads, and once the thread is created exceeds this value, tomcat closes the socket thread that is no longer needed;


Uriencoding= "GBK" to set tomcat default transcoding format

Check out this documentation for $tomcat_home/webapps/tomcat-docs/config/http.html, with the following instructions:
URIENCODING:THIS Specifies the character encoding used to decode the URI of bytes, after%xx decoding the URL. If not specified, iso-8859-1 'll be used. That is, if the uriencoding is not set, tomcat defaults to iso-8859-1 URL decoding, Iso-8859-1 does not include Chinese characters, so that the words in Chinese characters must not be correctly parsed.


Reprint someone else's blog:

A. Tomcat Connection pool configuration
Tomcat wants to withstand large concurrent volumes and must increase the number of connections, and the general Tomcat Connector can be modified as follows:

<connector port= "protocol=" http/1.1 "connectiontimeout=" 60000 "redirectport=" 8443
    = "5000" 
    acceptcount= "minsparethreads="
    maxsparethreads= "5000"
    enablelookups= "false"
    compression= "On" "
    compressionminsize=" 2048 "
    compressablemimetype=" text/html,text/xml,text/ Javascript,text/css,text/plain "
    disableuploadtimeout=" true "
    uriencoding=" UTF-8 "
/>

Some of these key parameters:
connectiontimeout: The connection timed out, in milliseconds. For high concurrency on-demand is not high, you can increase the value appropriately
maxthreads: Maximum number of concurrent connections
Acceptcount: The number of queues that can be accepted after the maximum number of connections is exceeded
minsparethreads: The number of threads created by default when Tomcat initializes, and the minimum number that is incremented once the thread increases
maxsparethreads: This parameter identifies that, once the number of threads created exceeds this value, Tomcat closes the inactive thread
enablelookups: Turn off DNS queries
In the implementation, we found that the use of this configuration, the number of connections after the difficult to drop, causing the CPU has been maintained at a relatively high level.

Then we switched to a connection, using the thread pool approach, first defining a executor:

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

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

<connector executor= "Tomcatthreadpool"
           port= "
           20003" protocol= "http/1.1" acceptcount= " minprocessors= "maxprocessors"
           = "1000"
           redirectport= "8443"/>


Minprocessors,maxprocessors is similar to the minsparethreads,maxthreads above.
After using the connection pool, it is found that if the number of connections has not been requested for a period of time, the number of connections will drop quickly and the CPU consumption is effectively reduced.
Processing capacity has been enhanced.





How do I see the number of current Tomcat connections?

Let's say 2 tomcat instances are on the server, listening to ports 8040 and 8050, 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

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.