Been wondering how this should be done.
On previous versions of apache (in debian 9) this is how I was doing it.
This way I could limit size of php pool and if pool reached it's max, apache would queue up requests and unless we reached acquire
delay (here 10s) in the queue, no errors would spit out
<IfModule proxy_fcgi_module>
# on previous versions of apache, having enablereuse on socks would hang
# when php reached it's max number of requests (set in fpm pool)
<Proxy "unix:/run/php/pool.php7.3-fpm.sock|fcgi://pool-php-7-3" enablereuse=Off max=5 >
ProxySet connectiontimeout=3 timeout=30 acquire=10
</Proxy>
</IfModule>
<VirtualHost *>
ServerName example.com
DocumentRoot /path/to/docroot
<Directory /path/to/docroot>
Options +Indexes
AllowOverride all
Require all granted
</Directory>
<IfModule proxy_fcgi_module>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:fcgi://pool-php-7-3"
</FilesMatch>
</IfModule>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# CustomLog /dev/null
# ErrorLog /dev/null
</VirtualHost>
Now on more recent versions of apache it seems that we want to have enablereuse=On
or have really poor performance.
I'm trying to get this to work nicely on a VPS.
thanks for advices on how this should be defined in recent versions of apache2.4 It's nicer to have users wait a couple seconds more when php pool reached it's maximum than to throw them an error. I use to have this working nicely before :)
Perhaps I'm not phrasing this the write way for apache ?
I finally found out that I was asking myself the wrong question! (as often when not finding the answer)
So back in time apache was able to handle this, but seems that on recent version it's not doing a good job of it because there is a better way!!
As php-fpm can handle a backlog queue, no need to control it at apache level. FPM pool manager can handle a 'first in first out' (aka fifo) queue so not to refuse connections
Look into /etc/php/7.3/fpm/pool.d/www.conf
for the "out of the box" and you'll find those lines, just uncomment the line
; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511
So just tell apache fcgi proxy to allow as many as 511... in my case, 50 would be plenty enough, but 511 is the default and seems to work well for me (site is a WordProuut ~5 pages/s)
<IfModule proxy_fcgi_module>
<Proxy "unix:/run/php/pool.php7.3-fpm.sock|fcgi://pool-php-7-3" enablereuse=Off max=511 >
ProxySet connectiontimeout=3 timeout=30 acquire=10
</Proxy>
</IfModule>
I did give a try with enablereuse=On
but seemed to me it still threw out an error when php-process reached it's pm.max_requests
. Works nicely with enablereuse=Off