From 5ed72c94fb3ec2ecdc9ba663446c26128bd703cf Mon Sep 17 00:00:00 2001 From: markt Date: Thu, 5 May 2011 15:01:46 +0000 Subject: [PATCH] Add disableKeepAlivePercentage attribute to the HTTP-BIO connector git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099834 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/coyote/http11/Http11Processor.java | 20 ++++++++++++++++++-- java/org/apache/coyote/http11/Http11Protocol.java | 19 +++++++++++++++++++ webapps/docs/changelog.xml | 5 +++++ webapps/docs/config/http.xml | 8 ++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index 94dc4c7cb..bff093cc0 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -118,6 +118,12 @@ public class Http11Processor extends AbstractHttp11Processor { protected JIoEndpoint endpoint; + /** + * The percentage of threads that have to be in use before keep-alive is + * disabled to aid scalability. + */ + private int disableKeepAlivePercentage = 75; + // --------------------------------------------------------- Public Methods @@ -137,6 +143,16 @@ public class Http11Processor extends AbstractHttp11Processor { } + public int getDisableKeepAlivePercentage() { + return disableKeepAlivePercentage; + } + + + public void setDisableKeepAlivePercentage(int disableKeepAlivePercentage) { + this.disableKeepAlivePercentage = disableKeepAlivePercentage; + } + + /** * Process pipelined HTTP requests on the specified socket. * @@ -181,8 +197,8 @@ public class Http11Processor extends AbstractHttp11Processor { / endpoint.getMaxThreads(); } // Disable keep-alive if we are running low on threads - if (threadRatio > 75) { - keepAliveLeft = 1; + if (threadRatio > getDisableKeepAlivePercentage()) { + keepAliveLeft = 1; } try { diff --git a/java/org/apache/coyote/http11/Http11Protocol.java b/java/org/apache/coyote/http11/Http11Protocol.java index 8c41dc33b..b55efacff 100644 --- a/java/org/apache/coyote/http11/Http11Protocol.java +++ b/java/org/apache/coyote/http11/Http11Protocol.java @@ -82,6 +82,23 @@ public class Http11Protocol extends AbstractHttp11JsseProtocol { protected Http11ConnectionHandler cHandler; + // ------------------------------------------------ HTTP specific properties + // ------------------------------------------ managed in the ProtocolHandler + + private int disableKeepAlivePercentage = 75; + public int getDisableKeepAlivePercentage() { + return disableKeepAlivePercentage; + } + public void setDisableKeepAlivePercentage(int disableKeepAlivePercentage) { + if (disableKeepAlivePercentage < 0) { + this.disableKeepAlivePercentage = 0; + } else if (disableKeepAlivePercentage > 100) { + this.disableKeepAlivePercentage = 100; + } else { + this.disableKeepAlivePercentage = disableKeepAlivePercentage; + } + } + // ----------------------------------------------------- JMX related methods @Override @@ -239,6 +256,8 @@ public class Http11Protocol extends AbstractHttp11JsseProtocol { processor.setSocketBuffer(proto.getSocketBuffer()); processor.setMaxSavePostSize(proto.getMaxSavePostSize()); processor.setServer(proto.getServer()); + processor.setDisableKeepAlivePercentage( + proto.getDisableKeepAlivePercentage()); register(processor); return processor; } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 54f3350eb..6a9317237 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -160,6 +160,11 @@ Improve handling in AJP connectors of the case where too large a AJP packet is received. (markt) + + Restore the automatic disabling of HTTP keep-alive with the BIO + connector once 75% of the processing threads are in use and make the + threshold configurable. (markt) + diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml index bf619a958..483f1049e 100644 --- a/webapps/docs/config/http.xml +++ b/webapps/docs/config/http.xml @@ -549,6 +549,14 @@ + +

The percentage of processing threads that have to be in use before + HTTP keep-alives are disabled to improve scalability. Values less than + 0 will be changed to 0 and values greater than + 100 will be changed to 100. If not specified, + 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 -- 2.11.0