Too many open files - mod_fcgid - ULIMIT Apache

Bierteufel

Registered User
Hallo,

ich habe ein kleines Problem:

System:

CENTOS 5.x
PSA 9.5.X
Apache mittels mod_fcgid (teilweise VHOST mit eigenen PHP.INIs)
RAM zweistellig GB..

CGI Wrapper:

PHP:
#!/bin/sh
PHPRC="/etc/php-ini.d/php-${UID}.ini"
[ -f ${PHPRC} ] || PHPRC="/etc/php.ini"
export PHPRC
exec /usr/bin/php-cgi

FCGID.CONF

PHP:
LoadModule fcgid_module /usr/lib64/httpd/modules/mod_fcgid.so

<IfModule mod_fcgid.c>
  SocketPath /var/lib/httpd/fcgid/sock
</IfModule>

<IfModule mod_fcgid.c>
  IdleTimeout 3600
  ProcessLifeTime 7200
  MaxProcessCount 128
  DefaultMaxClassProcessCount 16
  IPCConnectTimeout 30
  IPCCommTimeout 45
  DefaultInitEnv RAILS_ENV production
</IfModule>


Folgende Fehlermeldung kommt ab & zu:

Code:
[error] (24)Too many open files: mod_fcgid: couldn't set child process attributes: /var/lib/apache2/fcgid/sock/####.#####
[warn] (24)Too many open files: mod_fcgid: spawn process /var/www/test.tld/html/test.php error

Ein ulimit -a liefert mir: 1024 Files

Dieses habe ich schon gelesen:

http://wherethebitsroam.com/blogs/j...modfcgid-couldnt-set-child-process-attributes

Wie kann ich die Ulimits für den Apache erhöhen, so dass die Config auch greift ?

Oder sollte ich im CGI Wraper noch

PHP_FCGI_CHILDREN=0 (automatisch ?)

setzen ?
 
Darf ich rein Interesse halber mal fragen, warum die überhaupt die fgcid.conf manuell erstellt hast? Das ist bei Plesk 9.5.X und deinem modifizierten php-cgi-wrapper und somit einer vhost-spezifischen php.ini nicht zwangsläufig nötig.

Danke und Gruß
 
@BruceLee - Das ist ne gute Frage. Laut meinen Notizen habe ich dies damals gemacht, damit ich die dort genannten Parameter einstellen konnte...

Also:

Code:
 IdleTimeout 3600
  ProcessLifeTime 7200
  MaxProcessCount 128
  DefaultMaxClassProcessCount 16
  IPCConnectTimeout 30
  IPCCommTimeout 45
  DefaultInitEnv RAILS_ENV production

Du meinst die bringen nichts ?

Zurück zum Thema, ich bin mir halt noch nicht sicher obs auch wirklich am FileLimit (also evtl. doch nicht die Ulimits ) liegt oder evtl. doch am FCGID ?
Hast Du evtl. noch eine Idee ?
 
Nun, das sind die fcgid directiven. Von daher werden sie schon etwas bringen.
Diese sind aber schon in der /etc/httpd/conf.d/fcgid.conf konfiguriert.

Gleiche Sie mal ab und falls du keine Notwenigkeit siehst nimm die fcgid.conf einfach raus.

Jedoch glaube ich nicht, dass es die Lösung sein muss, aber einen Test ist es wert. Kannst du den Fehler reproduzieren?
PHP_FCGI_CHILDREN würde ich nicht setzen. Hier nachzulesen:
http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

ulimit müßte an unterschiedlichen Stellen "angepasst" werden. Das ist aber meiner Meinung nach stark mit Vorsicht zu genießen.
Hier wäre eine kleine Anleitung zu finden:
QUELLE:
http://www.virtualmin.com/node/8198


.....
5- This point is only for experts! Don't do it if you don't know what are you doing! (don't forget to do backups)

Type:

ulimit -n

if you see 1024 you can increase this number by doing this:

*

In /etc/security/limits.conf add this 2 lines:
*

soft nofile 4096
*

hard nofile 4096
*

In /etc/pam.d/login add this line:

session required pam_limits.so

* In /etc/rc.d/rc.local add this line:

ulimit -n 4096

* reboot

6- Adding this line in /etc/httpd/conf.d/fcgid.conf

MaxRequestsPerProcess 500

You should stop getting this error in /var/log/http/error_log:

Too many open files: mod_fcgid: couldn't set child ...

Don't forget to restart your apache (/etc/init.d/httpd restart)

....
 
Last edited by a moderator:
So sehe ich es auch auch, von den Ulimits lasse ich erstmal die Finger, ich versuche mal die FCGID Parameter noch anzupassen..
 
Also die letzten Tage habe ich ziemlich rum probiert und musste feststellen, dass es wohl oder überl an den

FCGID.CONF Parametern zu scheinen liegt.

Je nachdem wie ich es einstelle, werden entweder die Limts erreicht, Prozesse nicht mehr gespawnt oder es erscheint too many open files...

Kann mir evtl. mal hier einer seine FCGID.CONF Settings posten.

Im Moment fahre ich mit folgende Parametern:

Code:
BusyScanInterval 120
DefaultMaxClassProcessCount 15
DefaultMinClassProcessCount 0
ErrorScanInterval 6
IPCCommTimeout 120
IPCConnectTimeout 30
IdleScanInterval 240
IdleTimeout 600
MaxProcessCount 750
MaxRequestsPerProcess 500
ProcessLifeTime 3600
SpawnScore 1
SpawnScoreUpLimit 10
TerminationScore 2
ZombieScanInterval 6
 
Also ich denke dass der Hase wohl hier begraben liegt ...

http://wherethebitsroam.com/blogs/jeffw/apache-php-fastcgi-and-phpfcgichildren

You should set PHP_FCGI_CHILDREN=0 if you are using a dynamic configuration via FastCgiConfig. Only set PHP_FCGI_CHILDREN=4 or other non-zero value if you have specified a static fastcgi server using FastCgiServer.

If you are using a dynamic configuration _and_ a non-zero value, then Apache and php-cgi will both try to manage the number of php-cgi processes and you will get too many.
 
Back
Top