From: Eric Covener
Date: Sat, 20 Dec 2014 15:38:27 +0000 (+0000)
Subject: Allow (a hokey) opt-in to connection reuse for mod_proxy_fcgi + TCP.
X-Git-Tag: 2.5.0-alpha~3602
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2af6b8f57fe43e2026a2038ee68ee3e926f0503e;p=apache
Allow (a hokey) opt-in to connection reuse for mod_proxy_fcgi + TCP.
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
---
diff --git a/CHANGES b/CHANGES
index c5fd33792b..38335d51e2 100644
--- 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]
diff --git a/docs/manual/mod/mod_proxy_fcgi.xml b/docs/manual/mod/mod_proxy_fcgi.xml
index 4a8ce078fb..e032ca474f 100644
--- a/docs/manual/mod/mod_proxy_fcgi.xml
+++ b/docs/manual/mod/mod_proxy_fcgi.xml
@@ -68,30 +68,26 @@
- This application should be able to handle multiple concurrent
- connections. mod_proxy 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 ProxyPass directive, as shown in
- the following example:
-
- Single application instance, no connection reuse
+ mod_proxy_fcgi 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:
+
+ Single application instance, connection reuse
- ProxyPass /myapp/ fcgi://localhost:4000/ disablereuse=on
+ ProxyPass /myapp/ fcgi://localhost:4000/ disablereuse=off
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.
+ PHP-FPM is listening. Connection pooling is enabled.
PHP-FPM
- ProxyPassMatch ^/myapp/.*\.php(/.*)?$ fcgi://localhost:9000/var/www/
+ ProxyPassMatch ^/myapp/.*\.php(/.*)?$ fcgi://localhost:9000/var/www/ disablereuse=off
@@ -101,7 +97,8 @@
the hostname and optional port following fcgi:// are ignored.
PHP-FPM with UDS
- 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/"
diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c
index f53eb0e008..313db70117 100644
--- a/modules/proxy/mod_proxy_fcgi.c
+++ b/modules/proxy/mod_proxy_fcgi.c
@@ -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)) {