Apache + mod_fcgid, no option settings for number of process on start

Hello,

i have production server with Centos 6 with apache2.2 + mod_fastcgi, and becouse Centos 6 will be eof in November 30th, 2020, i must go to Centos 8 and i not found mod_fastcgi in repository for Centos 7/8. I think the mod_fastcgi is not maintain.

I looked to documentation i try apache/2.4.37 + mod_fcgid/2.3.9 (repo AppStream) and i try settings number of start process, but I not found some configuration option. Is some option how i can settings it? Becouse first user/connection must wait about 1 second then process is create, or if is more users/connection than processes in same time, so user must wait than next proces is created. Do you some experinece with mod_fcgid?

Thak you.

Maybe this config option:
https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidmaxprocesses

Thank you by reply.
FcgidMaxProcesses is maximum number of process, so restriction or defense against exhaustion sources (RAM), this option do not create initial processes after start web server.

For example in php-fpm is option called “pm.start_servers” It is the number of child processes created on startup.

There is my testing configuration mod_fcgid:
FcgidMaxRequestLen 1073741824
FcgidIPCDir /run/mod_fcgid/sock
FcgidProcessTableFile /run/mod_fcgid/fcgid_shm
FcgidIdleTimeout 0 #disable check timeout idle process
FcgidProcessLifeTime 0 #disable check life time of process
FcgidMaxRequestsPerProcess 1000 #close process after 1000 request
FcgidMaxProcesses 10 #maximum of number of process
FcgidMaxProcessesPerClass 10 #maximum of number of process for application/user
FcgidMinProcessesPerClass 0 #minimum of number of process fo application/user (disable)
FcgidSpawnScore 1
FcgidSpawnScoreUpLimit 1000
FcgidTerminationScore 1
FcgidTimeScore 1

It seems this thread could point you in a good direction:

I read this article but not describe exactly my problem.
In mod_fastcgi is option FastCgiServer (FastCgiServer /opt/rt4/sbin/rt-server.fcgi -processes 5 -idle-timeout 300), that create permanently (on startup apache) five process for fastcgi application (static pool), but I thing that mod_fastcgi is not maintain. And therefore i must use mod_fcgid or something else.

For example test connection over ab (apache benchmark):

  • After restart service apache (no processes for FCGI application):
    ab -n 20 -c 5 https://helpdesk.xxx.zz/
    Time taken for tests: 4.773 seconds (output shorted)

-Now five process for FCGI application is ready:
ab -n 20 -c 5 https://helpdesk.xxx.zz/
Time taken for tests: 0.213 seconds (output shorted)

In production server with Centos 6 with apache/2.2 + mod_fastcgi (with pernament 5 process on startup):
ab -n 20 -c 5 https://helpdesk.xxx.zz/

  • Time taken for tests: 0.231 seconds

Create new process for FCGI application consume about 1 second, i need way How i can start and stay minimal several process after start apache.

There is my testing configuration vhost:
<VirtualHost [xxx]:443 xxx:443>
ServerAdmin root@xxx
DocumentRoot “/opt/rt4/share/html”
ServerName xxx.yy
ErrorLog logs/xxx/ssl_error.log
CustomLog logs/xxx/ssl_access.log combined
LogLevel debug

FcgidInitialEnv PERL5LIB "/home/rt/perl5/lib/perl5"
FcgidInitialEnv LD_LIBRARY_PATH "/usr/lib/rt/12.2/client64/lib"

AddDefaultCharset UTF-8
ScriptAlias / /opt/rt4/sbin/rt-server.fcgi/

<Location />
    Require all granted
    Options +ExecCGI
    AddHandler fcgid-script fcgi
</Location>

SSLEngine on

SSLCertificateFile /etc/httpd/conf/ssl/server.crt
SSLCertificateKeyFile /etc/httpd/conf/ssl/server.key
SSLCertificateChainFile /etc/httpd/conf/ssl/server-chain.crt

<Files ~ "\.(cgi|shtml|phtml|php3?)$">
   SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

SetEnvIf User-Agent ".*MSIE.*" \
     nokeepalive ssl-unclean-shutdown \
     downgrade-1.0 force-response-1.0

CustomLog logs/xxx/ssl_request_log \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b %P"

I am not an Apache expert but it looks like you can set the number of StartServers for Event MPM, what do you have for your MPM config?

I use MPM Event, i usually use default configuration, so this:

<IfModule mpm_event_module>
StartServers 3
MinSpareThreads 75
MaxSpareThreads 250
ThreadLimit 64
ThreadsPerChild 25
MaxClients 400
MaxConnectionsPerChild 0
</IfModule>

I tryed various combination to settings but this was not help, next i tryed MPM worker and prefork but this was not help, so process start after visit website, there is screenshot (before, after visit website)

I read new documentation for RT 5.0.0, section for web development, and It was remove way over mod_fastcgi, and add recommandition to use MPM prefork.

Next i found some forum, where resolving this problem (https://serverfault.com/questions/319857/can-mod-fcgid-maintain-a-hard-minimum-number-of-available-appserver-processes), and he writted that is not possible.

Maybe exists some workaround, so some script, some edit systemd script for apache. I do not want to use utility ab for hard start several of process after start apache.