Zieh Dir bei z. Bsp. Debian fastcgid aus den unstable sourcen und bau Dir das Paket. Du kannst in der libapache2-mod-fcgid-2.2/fcgid_conf.c setzen vor dem Kompilieren:
Code: Select all
#define DEFAULT_IDLE_TIMEOUT 600
#define DEFAULT_IDLE_SCAN_INTERVAL 240
#define DEFAULT_BUSY_TIMEOUT 300
#define DEFAULT_BUSY_SCAN_INTERVAL 120
#define DEFAULT_SHUTDOWN_TIMEOUT 20
#define DEFAULT_ERROR_SCAN_INTERVAL 6
#define DEFAULT_ZOMBIE_SCAN_INTERVAL 6
#define DEFAULT_PROC_LIFETIME (60*60)
#define DEFAULT_SOCKET_PREFIX "/var/lib/apache2/fcgid/sock"
#define DEFAULT_SHM_PATH "/var/lib/apache2/fcgid/shm"
#define DEFAULT_SPAWNSOCRE_UPLIMIT 10
#define DEFAULT_SPAWN_SCORE 1
#define DEFAULT_TERMINATION_SCORE 2
#define DEFAULT_TIME_SCORE 1
#define DEFAULT_MAX_PROCESS_COUNT 500
#define DEFAULT_MAX_CLASS_PROCESS_COUNT 10
#define DEFAULT_MIN_CLASS_PROCESS_COUNT 0
#define DEFAULT_IPC_CONNECT_TIMEOUT 60
#define DEFAULT_IPC_COMM_TIMEOUT 120
#define DEFAULT_OUTPUT_BUFFERSIZE 65536
#define DEFAULT_MAX_REQUESTS_PER_PROCESS 500
#define DEFAULT_MAX_REQUEST_LEN (1024*1024*1024) /* 1G */
#define DEFAULT_MAX_MEM_REQUEST_LEN (1024*64) /* 64k */
Bewährt sich folgende Konfig für einen frequentierten Server:
Code: Select all
<IfModule mod_fcgid.c>
# IdleTimeout n (300 seconds)
# An idle fastcgi application will be terminated after IdleTimeout seconds.
IdleTimeout 600
# IdleScanInterval n (120 seconds)
# The scan interval for idle fastcgi applications.
IdleScanInterval 240
# BusyTimeout n (300 seconds)
# A fastcgi application will be terminated if handing a single request
# longer than busy timeout.
BusyTimeout 300
# BusyScanInterval n (120 seconds)
# The scan interval for busy timeout fastcgi applications.
BusyScanInterval 120
# ErrorScanInterval n (3 seconds)
# The scan interval for exit pending fastcgi applications. fastcgi
# applications will be terminated within this scanning.
ErrorScanInterval 6
# ZombieScanInterval n (3 seconds)
# The scan interval for zombie process.
ZombieScanInterval 6
# ProcessLifeTime n (3600 seconds)
# A fastcgi application will be terminated if lifetime expired,
# even no error is detected.
ProcessLifeTime 3600
# SocketPath path (logs/fcgidsock)
# The directory to put the UNIX domain socket. (UNIX only)
# This directory should be writable only by apache user
SocketPath /var/lib/apache2/fcgid/sock
#SharememPath path (logs/fcgid_shm)
#The share memory file path. (UNIX only) (version >= 2.1 only)
SharememPath /var/lib/apache2/fcgid/shm
# SpawnScoreUpLimit n (10)
# The spawn-speed control score up water limit. Score increases while
# a process is spawned or terminated, and decreases as time progresses;
# while the score is higher than SpawnScoreUpLimit, the spawning will be
# held for a while. The higher this number is, the higher speed of the
# spawning can be.
SpawnScoreUpLimit 10
# SpawnScore n (1)
# The weight of spawning. This weight will be plused to the spawn-control
# score on every spawn. The higher this number is, the lower speed of
# spawning can be.
SpawnScore 1
# TerminationScore n (2)
# The weight of termination. This weight will be plused to the score while
# fastcgi process terminates. The higher this number is, the lower speed
# of spawning can be.
TerminationScore 2
# MaxProcessCount n (1000)
# The max count of total fastcgi process count.
MaxProcessCount 250
# DefaultMaxClassProcessCount n (100)
# The maximum number of fastcgi application instances allowed to run for
# particular one fastcgi application.
DefaultMaxClassProcessCount 10
# DefaultMinClassProcessCount n (3)
# The minimum number of fastcgi application instances for any one fastcgi
# application.
# Idle fastcgi will not be killed if their count is less than n
# Set this to 0, and tweak IdleTimeout
DefaultMinClassProcessCount 0
# DefaultInitEnv env_name env_value
# The default environment variables before a fastcgi application
# is spawned. You can set this configuration more than once.
# IPCConnectTimeout n (3 seconds)
# The connect timeout to a fastcgi application.
IPCConnectTimeout 60
# IPCCommTimeout n (20 seconds)
# The communication timeout to a fastcgi application. Please increase this
# value if your CGI have a slow initialization or slow respond.
IPCCommTimeout 120
# OutputBufferSize n (64k bytes)
# CGI output cache buffer size.
# PHP_Fix_Pathinfo_Enable n(n=0/1, default 0)
# If you are using PHP and set cgi.fix_pathinfo=1 in php.ini, set PHP_Fix_Pathinfo_Enable 1.
# From php.ini:
# cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
# previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
# what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
# this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A setting
# of zero causes PHP to behave as before. Default is zero. You should fix your scripts
# to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
# cgi.fix_pathinfo=1
PHP_Fix_Pathinfo_Enable 1
MaxRequestsPerProcess 500
<Location /irgendwas/php-fcgi-starter>
SetHandler fcgid-script
Options +ExecCGI
</Location>
<Location /pfad/php4-fcgi-starter>
SetHandler fcgid-script
Options +ExecCGI
</Location>
AddHandler php-fastcgi .php
AddHandler php4-fastcgi .php4
Action php-fastcgi /irgendwas/php-fcgi-starter
Action php4-fastcgi /irgendwas/php4-fcgi-starter
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php4
</IfModule>
In der apache2.conf für den worker:
Code: Select all
Timeout 300
KeepAlive On
KeepAliveTimeout 2
MaxKeepAliveRequests 100
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 500
</IfModule>
In den php Starter kommt folgendes für php5:
Code: Select all
#!/bin/sh
PHPRC="/etc/apache2/pfad_zu_php-inis"
export PHPRC
PHP_FCGI_CHILDREN=0
export PHP_FCGI_CHILDREN
exec /pfad_zum_php-binary/php-fcgi
In den php Starter kommt folgendes für php4:
Code: Select all
#!/bin/sh
PHPRC="/etc/apache2/pfad_zu_php-inis"
export PHPRC
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
exec /pfad_zum_php-binary/php-fcgi
In der mysql.conf würde ich grundsätzlich setzen:
Code: Select all
# als crashed markierten Tabellen automatisch erkennen und reparieren
myisam_repair_threads = 1
myisam_recover = FORCE,BACKUP
Bei PHP4 wirst Du immer ein wenig mehr Prozesse haben, die nicht richtig gekillt werden können. Bei PHP5 klappt das schon ganz gut. Durch "PHP_FCGI_CHILDREN=0" wird auch die ganze Prozessverwaltung abgegeben. Dadurch starten nur neue Prozesse, wenn Sie auch angefordert werden, bzw. nicht gleich soviele.
Siehe oben. In der Config: "DefaultMinClassProcessCount 0". Dadurch killen sich bei mir auch die Prozess mit Idle richtig. Ab und zu kommt es immer noch zu kleineren Prozessausreißern, die einfach nicht gekillt werden. Aber das hält sich sehr in Grenzen.
Wenn man jetzt noch irgenwie den Speicher ernsthaft begrenzen könnte, dann läuft das alles schon recht gut.