Add disableKeepAlivePercentage attribute to the HTTP-BIO connector
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 5 May 2011 15:01:46 +0000 (15:01 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 5 May 2011 15:01:46 +0000 (15:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1099834 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11Processor.java
java/org/apache/coyote/http11/Http11Protocol.java
webapps/docs/changelog.xml
webapps/docs/config/http.xml

index 94dc4c7..bff093c 100644 (file)
@@ -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 {
index 8c41dc3..b55efac 100644 (file)
@@ -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;
         }
index 54f3350..6a93172 100644 (file)
         Improve handling in AJP connectors of the case where too large a AJP
         packet is received. (markt) 
       </fix>
+      <fix>
+        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)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">
index bf619a9..483f104 100644 (file)
     
     <attributes>
 
+      <attribute name="disableKeepAlivePercentage" required="false">
+        <p>The percentage of processing threads that have to be in use before
+        HTTP keep-alives are disabled to improve scalability. Values less than
+        <code>0</code> will be changed to <code>0</code> and values greater than
+        <code>100</code> will be changed to <code>100</code>. If not specified,
+        the default value is <code>75</code>.</p>
+      </attribute>
+
       <attribute name="maxConnections" required="false">
         <p>The maximum number of connections that the server will accept and
         process at any given time. When this number has been reached, the server