From 7c04d126ce93600089de95a2a29d7608b955ecfe Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 5 May 2011 15:42:59 +0000 Subject: [PATCH] Merge maxConnections and pollerSize for the APR connectors. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099850 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/ajp/AjpAprProtocol.java | 5 +++-- .../apache/coyote/http11/Http11AprProtocol.java | 4 ++-- java/org/apache/tomcat/util/net/AprEndpoint.java | 25 +++++++++++----------- webapps/docs/changelog.xml | 4 ++++ webapps/docs/config/http.xml | 24 ++++++++++++--------- 5 files changed, 36 insertions(+), 26 deletions(-) diff --git a/java/org/apache/coyote/ajp/AjpAprProtocol.java b/java/org/apache/coyote/ajp/AjpAprProtocol.java index 68facefbc..e056fee7b 100644 --- a/java/org/apache/coyote/ajp/AjpAprProtocol.java +++ b/java/org/apache/coyote/ajp/AjpAprProtocol.java @@ -94,8 +94,9 @@ public class AjpAprProtocol extends AbstractAjpProtocol { public int getPollTime() { return ((AprEndpoint)endpoint).getPollTime(); } public void setPollTime(int pollTime) { ((AprEndpoint)endpoint).setPollTime(pollTime); } - public void setPollerSize(int pollerSize) { ((AprEndpoint)endpoint).setPollerSize(pollerSize); } - public int getPollerSize() { return ((AprEndpoint)endpoint).getPollerSize(); } + // pollerSize is now a synonym for maxConnections + public void setPollerSize(int pollerSize) { endpoint.setMaxConnections(pollerSize); } + public int getPollerSize() { return endpoint.getMaxConnections(); } // ----------------------------------------------------- JMX related methods diff --git a/java/org/apache/coyote/http11/Http11AprProtocol.java b/java/org/apache/coyote/http11/Http11AprProtocol.java index 93a18d2e7..3fa7a5684 100644 --- a/java/org/apache/coyote/http11/Http11AprProtocol.java +++ b/java/org/apache/coyote/http11/Http11AprProtocol.java @@ -86,8 +86,8 @@ public class Http11AprProtocol extends AbstractHttp11Protocol { public int getPollTime() { return ((AprEndpoint)endpoint).getPollTime(); } public void setPollTime(int pollTime) { ((AprEndpoint)endpoint).setPollTime(pollTime); } - public void setPollerSize(int pollerSize) { ((AprEndpoint)endpoint).setPollerSize(pollerSize); } - public int getPollerSize() { return ((AprEndpoint)endpoint).getPollerSize(); } + public void setPollerSize(int pollerSize) { endpoint.setMaxConnections(pollerSize); } + public int getPollerSize() { return endpoint.getMaxConnections(); } public void setPollerThreadCount(int pollerThreadCount) { ((AprEndpoint)endpoint).setPollerThreadCount(pollerThreadCount); } public int getPollerThreadCount() { return ((AprEndpoint)endpoint).getPollerThreadCount(); } diff --git a/java/org/apache/tomcat/util/net/AprEndpoint.java b/java/org/apache/tomcat/util/net/AprEndpoint.java index e26a9388d..5b806e425 100644 --- a/java/org/apache/tomcat/util/net/AprEndpoint.java +++ b/java/org/apache/tomcat/util/net/AprEndpoint.java @@ -99,6 +99,14 @@ public class AprEndpoint extends AbstractEndpoint { protected ConcurrentLinkedQueue> waitingRequests = new ConcurrentLinkedQueue>(); + // ------------------------------------------------------------ Constructor + + public AprEndpoint() { + // Need to override the default for maxConnections to align it with what + // was pollerSize (before the two were merged) + setMaxConnections(8 * 1024); + } + // ------------------------------------------------------------- Properties @@ -112,14 +120,6 @@ public class AprEndpoint extends AbstractEndpoint { /** - * Size of the socket poller. - */ - protected int pollerSize = 8 * 1024; - public void setPollerSize(int pollerSize) { this.pollerSize = pollerSize; } - public int getPollerSize() { return pollerSize; } - - - /** * Size of the sendfile (= concurrent files which can be served). */ protected int sendfileSize = 1 * 1024; @@ -428,11 +428,12 @@ public class AprEndpoint extends AbstractEndpoint { acceptorThreadCount = 1; } if (pollerThreadCount == 0) { - if ((OS.IS_WIN32 || OS.IS_WIN64) && (pollerSize > 1024)) { + if ((OS.IS_WIN32 || OS.IS_WIN64) && (getMaxConnections() > 1024)) { // The maximum per poller to get reasonable performance is 1024 - pollerThreadCount = pollerSize / 1024; + pollerThreadCount = getMaxConnections() / 1024; // Adjust poller size so that it won't reach the limit - pollerSize = pollerSize - (pollerSize % 1024); + setMaxConnections( + getMaxConnections() - (getMaxConnections() % 1024)); } else { // No explicit poller size limitation pollerThreadCount = 1; @@ -1083,7 +1084,7 @@ public class AprEndpoint extends AbstractEndpoint { */ protected void init() { pool = Pool.create(serverSockPool); - int size = pollerSize / pollerThreadCount; + int size = getMaxConnections() / pollerThreadCount; int timeout = getKeepAliveTimeout(); if (timeout <= 0) { timeout = socketProperties.getSoTimeout(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 6a9317237..9151cc724 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -165,6 +165,10 @@ connector once 75% of the processing threads are in use and make the threshold configurable. (markt) + + Make pollerSize and maxConnections synonyms for the APR connectors since + they perform the same function. (markt) + diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index 483f1049e..425407123 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -350,6 +350,19 @@ connectionTimeout attribute.

+ +

The maximum number of connections that the server will accept and + process at any given time. When this number has been reached, the server + will not accept any more connections until the number of connections + falls below this value. The operating system may still accept + connections based on the acceptCount setting. Default value + varies by connector type. For BIO and NIO the default is + 10000. For APR/native, the default is 8192.

+

Note that for APR/native on Windows, the configured value will be + reduced to the highest multiple of 1024 that is less than or equal to + maxConnections. This is done for performance reasons.

+
+

The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 8192 (8 KB).

@@ -557,15 +570,6 @@ the default value is 75.

- -

The maximum number of connections that the server will accept and - process at any given time. When this number has been reached, the server - will not accept any more connections until the number of connections - falls below this value. The operating system may still accept - connections based on the acceptCount setting. Default value - is 10000.

-
-
@@ -740,7 +744,7 @@

Amount of sockets that the poller responsible for polling kept alive connections can hold at a given time. Extra connections will be closed right away. The default value is 8192, corresponding to 8192 keep-alive - connections.

+ connections. This is a synonym for maxConnections.

-- 2.11.0