]> granicus.if.org Git - apache/commitdiff
Allow (a hokey) opt-in to connection reuse for mod_proxy_fcgi + TCP.
authorEric Covener <covener@apache.org>
Sat, 20 Dec 2014 15:38:27 +0000 (15:38 +0000)
committerEric Covener <covener@apache.org>
Sat, 20 Dec 2014 15:38:27 +0000 (15:38 +0000)
Connection reuse has been disabled since r1032345 at the end of
2011.

Attempt to reverse the polarity of the connection reuse doc which
has been wrong for a long time.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1647005 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_proxy_fcgi.xml
modules/proxy/mod_proxy_fcgi.c

diff --git a/CHANGES b/CHANGES
index c5fd33792bf8174846a8220e7ab3a67d5a8a5b03..38335d51e25c869eaa72a553c5c1e8785d80cf84 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_proxy_fcgi: Enable opt-in to TCP connection reuse by explicitly
+     setting proxy option disablereuse=off. [Eric Covener] PR 57378.
   *) mod_proxy_fcgi: Remove proxy:balancer:// prefix from SCRIPT_FILENAME
      passed to fastcgi backends. [Eric Covener]
 
index 4a8ce078fbe63c6aec766d0194581b9c1b9979db..e032ca474fb41d859cbb9f4bf306ef3a53d73167 100644 (file)
       </highlight>
     </example>
 
-    <p>This application should be able to handle multiple concurrent
-    connections.  <module>mod_proxy</module> enables connection reuse by
-    default, so after a request has been completed the connection will be
-    held open by that httpd child process and won't be reused until that
-    httpd process routes another request to the application.  If the
-    FastCGI application is unable to handle enough concurrent connections
-    from httpd, requests can block waiting for the application to close
-    an existing connection.  One way to resolve this is to disable connection
-    reuse on the <directive>ProxyPass</directive> directive, as shown in
-    the following example:</p>
-
-    <example><title>Single application instance, no connection reuse</title>
+    <p> <module>mod_proxy_fcgi</module> disables connection reuse by
+    default, so after a request has been completed the connection will NOT be
+    held open by that httpd child process and won't be reused.  If the
+    FastCGI application is able to handle concurrent connections
+    from httpd, you can opt-in to connection reuse as shown in the following
+    example:</p>
+
+    <example><title>Single application instance, connection reuse</title>
     <highlight language="config">
-      ProxyPass /myapp/ fcgi://localhost:4000/ disablereuse=on
+      ProxyPass /myapp/ fcgi://localhost:4000/ disablereuse=off
       </highlight>
     </example>
 
     <p> The following example passes the request URI as a filesystem 
     path for the PHP-FPM daemon to run. The request URL is implicitly added 
     to the 2nd parameter. The hostname and port following fcgi:// are where
-    PHP-FPM is listening.</p>
+    PHP-FPM is listening.  Connection pooling is enabled.</p>
     <example><title>PHP-FPM</title>
     <highlight language="config">
-      ProxyPassMatch ^/myapp/.*\.php(/.*)?$ fcgi://localhost:9000/var/www/
+      ProxyPassMatch ^/myapp/.*\.php(/.*)?$ fcgi://localhost:9000/var/www/ disablereuse=off
     </highlight>
     </example>
 
     the hostname and optional port following fcgi:// are ignored.</p>
     <example><title>PHP-FPM with UDS</title>
     <highlight language="config">
-      ProxyPassMatch ^/(.*\.php(/.*)?)$ "unix:/var/run/php5-fpm.sock|fcgi://localhost/var/www/"
+      # UDS does not currently support connection reuse
+      ProxyPassMatch ^/(.*\.php(/.*)?)$ "unix:/var/run/php5-fpm.sock|fcgi://localhost/var/www/" 
     </highlight>
     </example>
 
index f53eb0e008c330e59adbf3cf5850136dd3fee16f..313db70117fd8675ae95c6823c6a1c8f409c4770 100644 (file)
@@ -834,11 +834,15 @@ static int proxy_fcgi_handler(request_rec *r, proxy_worker *worker,
         goto cleanup;
     }
 
-    /* XXX Setting close to 0 is a great way to end up with
-     *     timeouts at this point, since we lack good ways to manage the
-     *     back end fastcgi processes.  This should be revisited when we
-     *     have a better story on that part of things. */
+    /* This scheme handler does not reuse connections by default, to
+     * avoid tieing up a fastcgi that isn't expecting to work on 
+     * parallel requests.  But if the user went out of their way to
+     * type the default value of disablereuse=off, we'll allow it.
+     */  
     backend->close = 1;
+    if (worker->s->disablereuse_set && !worker->s->disablereuse) { 
+        backend->close = 0;
+    }
 
     /* Step Two: Make the Connection */
     if (ap_proxy_connect_backend(FCGI_SCHEME, backend, worker, r->server)) {