.png)
Nach 6-stündigem Debuggen gebe ich es auf :|
Wir haben ein nginx+php-fpm+mysql im LAN mit fast 100 WordPress (erstellt und verwendet von verschiedenen Designern/Entwicklern, die alle an Test-WordPress-Setups arbeiten)
Wir verwenden Nginx schon lange ohne Probleme.
Heute hat Nginx plötzlich aus heiterem Himmel angefangen, „504 Gateway Time-out“ zurückzugeben ...
Ich habe das Nginx-Fehlerprotokoll für einen virtuellen Host überprüft …
2010/09/06 21:24:24 [error] 12909#0: *349 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:11 [error] 12909#0: *349 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:11 [error] 12909#0: *443 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 21:25:12 [error] 12909#0: *443 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:08:32 [error] 12909#0: *1025 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:33 [error] 12909#0: *1025 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:40 [error] 12909#0: *1064 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:09:40 [error] 12909#0: *1064 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:24:44 [error] 12909#0: *1313 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
2010/09/06 22:24:53 [error] 12909#0: *1313 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.0.1, server: rahul286.rtcamp.info, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "rahul286.rtcamp.info"
Als ich php-fpm auf Port 9000 im TCP-Modus ausführte, führte ich „netstat | grep 9000“ aus und bemerkte etwas Ungewöhnliches … (Füge hier einen Teil der Ausgabe ein, um das Lesen zu erleichtern)
tcp 9 0 localhost:9000 localhost:36094 CLOSE_WAIT 14269/php5-fpm
tcp 0 0 localhost:46664 localhost:9000 FIN_WAIT2 -
tcp 1257 0 localhost:9000 localhost:36135 CLOSE_WAIT -
tcp 1257 0 localhost:9000 localhost:36125 CLOSE_WAIT -
tcp 9 0 localhost:9000 localhost:36102 CLOSE_WAIT 14268/php5-fpm
tcp 0 0 localhost:46662 localhost:9000 FIN_WAIT2 -
tcp 745 0 localhost:9000 localhost:46644 CLOSE_WAIT -
tcp 0 0 localhost:46658 localhost:9000 FIN_WAIT2 -
tcp 1265 0 localhost:9000 localhost:46607 CLOSE_WAIT -
tcp 0 0 localhost:46672 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1257 0 localhost:9000 localhost:36119 CLOSE_WAIT -
tcp 1265 0 localhost:9000 localhost:46613 CLOSE_WAIT -
tcp 0 0 localhost:46646 localhost:9000 FIN_WAIT2 -
tcp 1257 0 localhost:9000 localhost:36137 CLOSE_WAIT -
tcp 0 0 localhost:46670 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1265 0 localhost:9000 localhost:46619 CLOSE_WAIT -
tcp 1336 0 localhost:9000 localhost:46668 ESTABLISHED -
tcp 0 0 localhost:46648 localhost:9000 FIN_WAIT2 -
tcp 1336 0 localhost:9000 localhost:46670 ESTABLISHED -
tcp 9 0 localhost:9000 localhost:36108 CLOSE_WAIT 14274/php5-fpm
tcp 1336 0 localhost:9000 localhost:46684 ESTABLISHED -
tcp 0 0 localhost:46674 localhost:9000 ESTABLISHED 12909/nginx: worker
tcp 1336 0 localhost:9000 localhost:46666 ESTABLISHED -
tcp 1257 0 localhost:9000 localhost:46648 CLOSE_WAIT -
tcp 1336 0 localhost:9000 localhost:46678 ESTABLISHED -
tcp 0 0 localhost:46668 localhost:9000 ESTABLISHED 12909/nginx: wo
Es gibt viele „CLOSE_WAIT“- und „FIN_WAIT2“-Paare, wie unten hervorgehoben (in der obigen Ausgabe):
tcp 1337 0 localhost:9000 localhost:46680 CLOSE_WAIT -
tcp 0 0 localhost:46680 localhost:9000 FIN_WAIT2 -
Bitte beachten Sie oben Port 46680.
Ich habe das Fehlerprotokoll für langsame MySQL-Abfragen aktiviert, aber es hat nicht funktioniert.
Ab sofort starte ich php5-fpm jede Minute über einen Cronjob neu (siehe Befehl unten), damit alles „reibungslos“ läuft, aber ich hasse Flickwerk und möchte das lösen …
1 * * * * service php5-fpm restart > /dev/null
Ich habe ausführlich bei Google gesucht, aber keine Hilfe bekommen. Wie erwähnt handelt es sich hier um einen Testserver im LAN, die CPU-Auslastung überschreitet nie 0,10 und die Speichernutzung liegt auch unter 25 % (das System hat 2 GB RAM und einen Ubuntu-Server installiert). Wenn Sie also zu viel Zeit damit verbringen, mir zu helfen, hinterlassen Sie mir bitte wenigstens einen Hinweis.
Vielen Dank im Voraus für die Hilfe.
-Rahul
(Hinweis: Dies ist eine Neuveröffentlichung von:http://forum.nginx.org/read.php?11,127694)
Update: Ich habe die Antwort gefunden, die unten gepostet ist.
Antwort1
Ich habe eine Antwort auf meinen Beitrag im Nginx-Forum gefunden -http://forum.nginx.org/read.php?2,127854
In meinem Fall besteht die Antwort darin, Folgendes festzulegen:
request_terminate_timeout=30s
in der php-fpm-Konfiguration (normalerweise /etc/php5/fpm/php-fpm.conf
)
Beachten Sie, dass Sie auch andere Werte als 30 s verwenden können.
Ich habe es verwendet, um meinen Wert in der Hauptdatei abzugleichen php.ini
, der lautet:
max_execution_time = 30
Danke an alle. :-)
Antwort2
So wurde mein Problem gelöst:
nehmen Sie folgende Änderungen an /etc/nginx/nginx.conf im Abschnitt http { vor
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
und dann nginx neu starten
/etc/init.d/nginx neu starten
Antwort3
Wenn Sie PHP 5.3 verwenden, erhöhen Sie den Rückstand.
Wenn Sie PHP 5.2 verwenden, portieren Sie den Patch zurück, um die Backlog-Größe von 128 zu erhöhen.
Verwenden Sie außerdem einen Unix-Socket anstelle eines TCP-Sockets. unix:/tmp/php5-cgi.sock (oder der entsprechende Pfad)
Antwort4
in meinem Fall (dieselbe Nginx-Fehlermeldung) werden einige problematische PHP-Skripte nicht beendet und müssen auf etwas warten, sodass für Nginx keine untergeordneten PHP5-FPM-Elemente mehr zum Auswählen vorhanden sind.
Fix:
- Ausführungszeitlimit hinzufügen, andere haben es in diesem Beitrag erwähnt.
request_terminate_timeout=30s
- Kinderzahl erhöhen. und alles hat wie am Schnürchen geklappt.
pm.max_spare_servers=16
pm.min_spare_servers=2
jetzt hat alles wie am Schnürchen geklappt.