The correct way to modify the maximum number of concurrent connections in Tomcat 7

Source: Internet
Author: User
Tags nginx reverse proxy

The correct way to modify the maximum number of concurrent connections in Tomcat 7
[Date: 2013-09-20] Source: Linux Community qysh123 [Font: Big Small]

It was a very simple question, but the search took a turn and found that everyone had written it wrong. So here's a summary:

Almost all Chinese pages are introduced, to modify the default maximum number of concurrent connections tomcat, you should set the following (in fact, these steps are wrong):

--------------------------------------------

In the <connector .../> configuration in the Tomcat configuration file Server.xml, the parameters related to the number of connections are:
  
Minprocessors: Minimum number of idle connection threads for improved system processing performance with a default value of 10
Maxprocessors: Maximum number of connection threads, which is the maximum number of requests concurrently processed, with a default value of 75
Acceptcount: Maximum number of connections allowed, should be greater than or equal to Maxprocessors, default value is 100
Enablelookups: Whether to reverse the domain name, the value is: TRUE or false. To improve processing power, set to False
ConnectionTimeout: Network connection time-out, unit: milliseconds. Set to 0 to never time out, so the setting is hidden. It can usually be set to 30000 milliseconds.
The parameters associated with the maximum number of connections are maxprocessors and Acceptcount. If you want to increase the number of concurrent connections, both parameters should be increased.
The maximum number of connections allowed by Web server is also subject to the kernel parameter settings of the operating system, usually Windows is about 2000, and Linux is about 1000. For how to set these parameters in Unix, see Common UNIX monitoring and Management commands

Specific configuration information:
Java code
<connector classname= "Org.apache.coyote.tomcat4.CoyoteConnector" port= "8080"
minprocessors= "5" maxprocessors= "enablelookups=" true "redirectport=" 8443 "
acceptcount= "debug=" 0 "connectiontimeout=" 20000 "useurivalidationhack=" false "
Protocolhandlerclassname= "Org.apache.jk.server.JkCoyoteHandler"/>

--------------------------------------------

But I looked through the loop and found that this was only baseless assertion, and not for Tomcat 5.5 or more. We'll teach you how to check Tomcat's website first:

First, here: http://tomcat.apache.org/We click on Tomcat 7.0 under "documentation" in the left navigation bar to enter this link: http://tomcat.apache.org/ Tomcat-7.0-doc/index.html, detailed information we do not have to look at, in the left navigation bar there is a link to the configuration, we click in the left navigation bar, then connector an item of HTTP, It goes to the settings page for the number of HTTP connections and other related properties. Here (http://tomcat.apache.org/tomcat-7.0-doc/config/http.html) we can see that in Connector's property configuration, there is no setting option for maxprocessors and so on. One of these words has been introduced very clearly:

If more simultaneous requests is received than can be handled by the currently available request processing threads, Addi tional threads'll is created up to the configured maximum (the value of the MaxThreads attribute). If still more simultaneous requests is received, they is stacked up inside the server sockets created by the Connector, u P to the configured maximum (the value of the Acceptcount attribute).

So the two values we need to set are MaxThreads and Acceptcount:

Among them, MaxThreads's introduction is as follows:

The maximum number of request processing threads to being created by this Connector, which therefore determines the maximum n Umber of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor are associated with this connector, this attribute is ignored as the connector would execute tasks using the Executor rather than an internal thread pool.

And Acceptcount's introduction is:

The maximum queue length for incoming connection requests if all possible request processing threads is in use. Any requests received if the queue is full would be refused. The default value is 100.

So the default values for both are 200 and 100, and to adjust the default maximum number of connections for Tomcat, you can increase the values of these two properties and make acceptcount greater than or equal to MaxThreads:

<connector port= "8080" protocol= "http/1.1"
connectiontimeout= "20000"
Redirectport= "8443" acceptcount= "maxthreads="/>

Today to record so much, I hope that we will be reproduced in other people's experience more carefully, do not always appear above those baseless assertion situation. Also hope to be able to help some friends.

Related reading:

Linux under Apache and multiple Tomcat cluster load balancer http://www.linuxidc.com/Linux/2012-01/51731.htm

Nginx Tomcat Cluster Load Balancing solution Note http://www.linuxidc.com/Linux/2013-07/86827.htm

Example of the Tomcat component installation +nginx reverse proxy tomcat+apache using MOD_JK and mod_proxy reverse proxy and load balancing http://www.linuxidc.com/Linux/2013-06/85290.htm

APACHE+TOMCAT Environment Construction (JK deployment process) http://www.linuxidc.com/Linux/2012-11/74474.htm

The correct way to modify the maximum number of concurrent connections in Tomcat 7

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.