Hi there,
There is one huge thing that needs to be done in order to make my FastCGI-driven system work: Apache2 has to be compiled with the Worker MPM.
Code:
root@edge:/usr/local/directadmin/custombuild# cat custom/ap2/configure.apache
#!/bin/sh
"./configure" \
"--prefix=/etc/httpd" \
"--exec-prefix=/etc/httpd" \
[...]
"--with-ssl=/usr" \
"--enable-headers" \
"--with-mpm=worker" \
"--enable-proxy-connect" \
[...]
As you can see, after "--enable-headers" I've added "--with-mpm=worker". The other things don't matter.
Here is the worker configuration:
Code:
root@edge:/etc/httpd/conf/extra# cat httpd-mpm.conf
[...]
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
StartServers 1
ServerLimit 4
MaxClients 256
MinSpareThreads 32
MaxSpareThreads 64
ThreadsPerChild 64
MaxRequestsPerChild 0
</IfModule>
[...]
- StartServers MUST be 1.
- ServerLimit should be set to 1 if you can't afford to have FastCGI to be run more then once. It's a failsave option, if you run 32 php-cgi processes and have 33 users connected at the same time 64 processes will be spawned. If you set 1 the 33th user will timeout.
- MaxClients should be the exact same amount of php-cgi processes spawned by FastCGI
- MaxRequestsPerChild MUST be 0 to have APC cache the opcode forever (or until apache is restarted)
The other values can be modified according to your performance needs.
Here is what the processes should look at the end:
Code:
$ pstree -u 27854
httpd─┬─httpd(apache)───65*[{httpd}]
├─httpd(apache)
└─httpd(apache)─┬─php-cgi(webapps)───256*[php-cgi]
├─php-cgi(tillo)───256*[php-cgi]
├─php-cgi(noirgame)───256*[php-cgi]
├─php-cgi(lithium)───256*[php-cgi]
└─php-cgi(exty)───256*[php-cgi]