Auf meinem Rootserver habe ich mit Apache seit geraumer Zeit ein Problem, welches ich leider nicht eingrenzen kann bzw. in den Griff bekomme. Und zwar passiert es alle paar Tage, dass Apache plötzlich aus durchschnittlich 20 Prozessen ca. 150-200 macht und anschließend nicht mehr erreichbar ist. Ein Neustart von Apache ist dann notwendig. In den Logs, egal ob access oder debug-error, findet sich kein Muster, welches ich erkennen kann. Zu den Zeitpunkten, zu denen das Problem auftritt, ist auch keine Erhöhung der Zugriffszahl festzustellen. Speziell sowas wie einen ddos gibt es nicht.
Aktuell läuft apache in Version 2.2.25 auf einem Gentoo Linux (64 Bit) mit Kernel 3.7.9 auf einem CoreI7 mit 16GB Ram. Verschiedene Versionsupdates von Apache oder PHP (aktuell Version 5.5.4) haben leider nichts an diesem Problem geändert. PHP-Prozesse werden via fcgid gestartet. Es werden ca. 220 Domains gehostet, die jedoch lediglich im Schnitt etwa 3-4 Requests/s produzieren - man kann also nicht behaupten, dass der Server großartig unter Last ist. Kommt es zum beschriebenen Problem, ist auch kein nennenswerter Anstieg des CPU-Loads zu verzeichnen.
Alle anderen Dienste (Bind, Postfix, Proftpd, Dovecot, MySQL ...) laufen stets ohne Probleme.
Irgendwer eine Idee, nach was ich mal schauen könnte?
Apache: viele Prozesse und Webdienst nicht mehr erreichbar
-
- Posts: 64
- Joined: 2003-12-03 02:32
- Location: Mainz
-
- Project Manager
- Posts: 11183
- Joined: 2003-02-27 01:00
- Location: Hamburg
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Poste bitte mal die Configs des MPM und von mod_fcgid.
Ich vermute mal, dass bei so verhältnismässig wenigen Requests die FastCGI-Prozesse gemeinsam ihre Lifetime erreichen und alle gleichzeitig restartet werden. Das könnte unter unglücklichen Umständen auch ein so potentes System wie Deines kurzfristig aus dem Tritt bringen und zu beschriebenem Verhalten führen.
Wie sehen denn Deine Compilerflags aus und steht eventuell etwas in den diversen Systemlogs?
Poste auch mal das debug-Log des Apache zu einem Hänger (plusminus fünf Minuten).
Ich vermute mal, dass bei so verhältnismässig wenigen Requests die FastCGI-Prozesse gemeinsam ihre Lifetime erreichen und alle gleichzeitig restartet werden. Das könnte unter unglücklichen Umständen auch ein so potentes System wie Deines kurzfristig aus dem Tritt bringen und zu beschriebenem Verhalten führen.
Wie sehen denn Deine Compilerflags aus und steht eventuell etwas in den diversen Systemlogs?
Poste auch mal das debug-Log des Apache zu einem Hänger (plusminus fünf Minuten).
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
-
- Posts: 64
- Joined: 2003-12-03 02:32
- Location: Mainz
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Also das gleichzeitige Beenden ist es wohl nicht - hier ist zB mal ein Auszug, wie das üblicherweise läuft:
[...]
[Mon Nov 04 10:27:48 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 1 processes
[Mon Nov 04 10:29:53 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 3 processes
[Mon Nov 04 10:31:51 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 3 processes
[Mon Nov 04 10:33:55 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
[Mon Nov 04 10:37:57 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
[...]
Das Problem trat zuletzt auf am "06/Nov/2013:20:00:21" - der letzte geloggt Zugriff war ein 404 auf ein .gif. Es folgen dann noch ca. 5,5min Einträge im Debug-Log, die mit Folgendem enden:
[Wed Nov 06 20:03:42 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 1 processes
[Wed Nov 06 20:05:48 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
In der Zwischenzeit findet man nur solche Sachen:
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1941): proxy: initialized single connection worker 7 in child 15894 for (*)
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1825): proxy: grabbed scoreboard slot 6 in child 15894 for worker http://localhost/stats/xxx.de
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1844): proxy: worker http://localhost/stats/xxx.de already initialized
Oder zlib-compressions:
[Wed Nov 06 20:03:31 2013] [debug] mod_deflate.c(615): [client xx.xx.xx.xx] Zlib: Compressed 18467 to 4913 : URL /xxx/js/lightbox.js, referer: http://www.xxx.de/xxx/xxx/xxx_index.php
Gerade sehe ich das hier noch, was offenbar die Erhöhung der Prozesse beschreibt:
Nov 06 20:00:00 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 18 total children
[Wed Nov 06 20:01:28 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 1 idle, and 41 total children
[Wed Nov 06 20:01:44 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 2 idle, and 54 total children
[Wed Nov 06 20:02:09 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 71 total children
[Wed Nov 06 20:02:19 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 93 total children
[Wed Nov 06 20:02:41 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 2 idle, and 123 total children
Wie gesagt: im regulären Log sieht man zu dem Zeitpunkt schon gar nix mehr.
Apache ist mit folgenden Flags kompiliert:
www-servers/apache-2.2.25:2 USE="ssl suexec -debug -doc -ldap (-selinux) -static -threads" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgid dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http reqtimeout rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -authn_alias -cern_meta -cgi -charset_lite -dumpio -log_forensic -proxy_ftp -proxy_scgi -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB
mpm sieht so aus:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 5000
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
fcgid:
AddHandler fcgid-script .php .php5
SocketPath /var/spool/fcgidsock
FcgidProcessTableFile /var/spool/fcgidsock/processtable
IPCConnectTimeout 20
FcgidMaxRequestsPerProcess 1000
FcgidPassHeader AUTHORIZATION
FcgidBusyTimeout 300
FcgidIOTimeout 300
FcgidMaxRequestLen 104857600
FcgidMaxProcesses 200
FcgidMaxProcessesPerClass 20
FcgidMinProcessesPerClass 0
Der Start erfolgt dann pro Domain über einen Wrapper so:
<IfModule fcgid_module>
<Directory /var/www/virtual/xxx.de/htdocs>
FCGIWrapper /var/www/fcgi/xxx.de/php5-fcgid-starter .php
Options +ExecCGI
</Directory>
<Directory "/var/www/fcgi/xxx.de">
AllowOverride None
Options +ExecCGI MultiViews -Indexes
Order allow,deny
Allow from all
</Directory>
</IfModule>
Das Compiling ist ohne besondere Flags:
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
=> Reicht dir das? :D
[...]
[Mon Nov 04 10:27:48 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 1 processes
[Mon Nov 04 10:29:53 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 3 processes
[Mon Nov 04 10:31:51 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 3 processes
[Mon Nov 04 10:33:55 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
[Mon Nov 04 10:37:57 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
[...]
Das Problem trat zuletzt auf am "06/Nov/2013:20:00:21" - der letzte geloggt Zugriff war ein 404 auf ein .gif. Es folgen dann noch ca. 5,5min Einträge im Debug-Log, die mit Folgendem enden:
[Wed Nov 06 20:03:42 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 1 processes
[Wed Nov 06 20:05:48 2013] [debug] fcgid_pm_main.c(357): mod_fcgid: gracefully terminated 4 processes
In der Zwischenzeit findet man nur solche Sachen:
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1941): proxy: initialized single connection worker 7 in child 15894 for (*)
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1825): proxy: grabbed scoreboard slot 6 in child 15894 for worker http://localhost/stats/xxx.de
[Wed Nov 06 20:02:40 2013] [debug] proxy_util.c(1844): proxy: worker http://localhost/stats/xxx.de already initialized
Oder zlib-compressions:
[Wed Nov 06 20:03:31 2013] [debug] mod_deflate.c(615): [client xx.xx.xx.xx] Zlib: Compressed 18467 to 4913 : URL /xxx/js/lightbox.js, referer: http://www.xxx.de/xxx/xxx/xxx_index.php
Gerade sehe ich das hier noch, was offenbar die Erhöhung der Prozesse beschreibt:
Nov 06 20:00:00 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 18 total children
[Wed Nov 06 20:01:28 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 1 idle, and 41 total children
[Wed Nov 06 20:01:44 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 2 idle, and 54 total children
[Wed Nov 06 20:02:09 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 71 total children
[Wed Nov 06 20:02:19 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 0 idle, and 93 total children
[Wed Nov 06 20:02:41 2013] [info] server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers), spawning 8 children, there are 2 idle, and 123 total children
Wie gesagt: im regulären Log sieht man zu dem Zeitpunkt schon gar nix mehr.
Apache ist mit folgenden Flags kompiliert:
www-servers/apache-2.2.25:2 USE="ssl suexec -debug -doc -ldap (-selinux) -static -threads" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgid dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http reqtimeout rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -authn_alias -cern_meta -cgi -charset_lite -dumpio -log_forensic -proxy_ftp -proxy_scgi -substitute -version" APACHE2_MPMS="-event -itk -peruser -prefork -worker" 0 kB
mpm sieht so aus:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 5000
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
fcgid:
AddHandler fcgid-script .php .php5
SocketPath /var/spool/fcgidsock
FcgidProcessTableFile /var/spool/fcgidsock/processtable
IPCConnectTimeout 20
FcgidMaxRequestsPerProcess 1000
FcgidPassHeader AUTHORIZATION
FcgidBusyTimeout 300
FcgidIOTimeout 300
FcgidMaxRequestLen 104857600
FcgidMaxProcesses 200
FcgidMaxProcessesPerClass 20
FcgidMinProcessesPerClass 0
Der Start erfolgt dann pro Domain über einen Wrapper so:
<IfModule fcgid_module>
<Directory /var/www/virtual/xxx.de/htdocs>
FCGIWrapper /var/www/fcgi/xxx.de/php5-fcgid-starter .php
Options +ExecCGI
</Directory>
<Directory "/var/www/fcgi/xxx.de">
AllowOverride None
Options +ExecCGI MultiViews -Indexes
Order allow,deny
Allow from all
</Directory>
</IfModule>
Das Compiling ist ohne besondere Flags:
CFLAGS="-O2 -pipe"
CXXFLAGS="${CFLAGS}"
CHOST="x86_64-pc-linux-gnu"
=> Reicht dir das? :D
-
- Project Manager
- Posts: 11183
- Joined: 2003-02-27 01:00
- Location: Hamburg
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Ja, in diesem Moment reicht das erstmal ;)
Bitte den Apache mit mindestens einem aktivierten MPM rekompilieren. Um das bisherige Verhalten Deines Apache nicht zu ändern, bitte MPM-Prefork wählen.
BTW: Bitte dem Gentoo-Apache-Maintainer in den Hintern treten (Bugreport), damit der Ebuild künftig immer einen MPM erzwingt (Default auf Prefork). So war es schon vor Jahren als ich Gentoo noch produktiv einsetzte, keine Ahnung wann Gentoo das verbockt hat.
Benötigst Du die Proxy-Module zwingend? Wenn nicht, dann raus damit.
Diese sind vermutlich die Ursache, denn Proxy-Zugriffe werden nicht ausführlich geloggt und zusätzlich ist die Konfiguration von mod_proxy sehr anfällig für ungewollte Fehler und öffnet dann bösen Buben einen Open-Proxy. Letzteres vermute ich bei Dir.
Der Rest sieht auf den ersten flüchtigen Blick unauffällig aus.
Bitte den Apache mit mindestens einem aktivierten MPM rekompilieren. Um das bisherige Verhalten Deines Apache nicht zu ändern, bitte MPM-Prefork wählen.
BTW: Bitte dem Gentoo-Apache-Maintainer in den Hintern treten (Bugreport), damit der Ebuild künftig immer einen MPM erzwingt (Default auf Prefork). So war es schon vor Jahren als ich Gentoo noch produktiv einsetzte, keine Ahnung wann Gentoo das verbockt hat.
Benötigst Du die Proxy-Module zwingend? Wenn nicht, dann raus damit.
Diese sind vermutlich die Ursache, denn Proxy-Zugriffe werden nicht ausführlich geloggt und zusätzlich ist die Konfiguration von mod_proxy sehr anfällig für ungewollte Fehler und öffnet dann bösen Buben einen Open-Proxy. Letzteres vermute ich bei Dir.
Der Rest sieht auf den ersten flüchtigen Blick unauffällig aus.
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
-
- Posts: 64
- Joined: 2003-12-03 02:32
- Location: Mainz
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Ok, schau ich mir morgen mal an.
Eins vorab: ich betreibe keinen Open Proxy, aber tatsächlich müsste ich mod_proxy mal auf den Prüfstand stellen.
Den Rest werde ich mal testen.
Danke schon mal an dieser Stelle.
Eins vorab: ich betreibe keinen Open Proxy, aber tatsächlich müsste ich mod_proxy mal auf den Prüfstand stellen.
Den Rest werde ich mal testen.
Danke schon mal an dieser Stelle.
-
- Posts: 64
- Joined: 2003-12-03 02:32
- Location: Mainz
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Ok, also bislang läuft Apache seit dem Recompiling am Wochenende stabil. Sieht erstmal gut aus, mal hoffen, dass es so bleibt.
Danke auf jeden Fall für den Tipp.
Danke auf jeden Fall für den Tipp.
-
- Project Manager
- Posts: 11183
- Joined: 2003-02-27 01:00
- Location: Hamburg
Re: Apache: viele Prozesse und Webdienst nicht mehr erreichb
Das hört sich schonmal gut an, hoffen wir dass es so bleibt.
PayPal.Me/JoeUser ● FreeBSD Remote Installation
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.
Wings for Life ● Wings for Life World Run
„If there’s more than one possible outcome of a job or task, and one
of those outcomes will result in disaster or an undesirable consequence,
then somebody will do it that way.“ -- Edward Aloysius Murphy Jr.