Nginx зацикливается при отправке запросов на fast-cgi и proxy

Владимир Туманов admin на mist-game.ru
Сб Дек 11 18:16:45 MSK 2010


Не так давно, перенёс проект со старого сервера на новый, разумеется софт
начал собирать заново. Для обработки PHP скриптов решил использовать
PHP-FPM+nginx.
Потом заметил, что пару раз в день нагрузка от fpm стала съедать все
ресурсы, попробовал перенести FPM на tcp сокет и увеличить число процессов -
не помогло.
Решил вернуться к старой проверенной схеме: nginx+apache+mod_php. Ситуация
та же, пару раз в день, apache съедает все возможные ресурсы.


netstat -Lan показывает огромную очередь к апачу и более мелкую к nginx, но
кроме nginx ни кто не может обращаться к 127.0.0.1:8080
tcp4  193/0/128      127.0.0.1.8080
tcp4  0/13/128       80.77.174.131.80
tcp4  0/12/128       80.77.174.132.80
tcp4  0/35/128       80.77.174.133.80


Лог nginx во время зависания:
2010/12/11 14:42:03 [warn] 30534#0: *3308488 a client request body is
buffered to a temporary file /tmp/nginx/client_temp/9/13/0000000139 while
sending request to upstream, client: 93.72.48.107, server:
world.mist-game.ru, request: "POST
/?ctrl=Location&a=refresh&__path=refresh&h=6cde2ab1d2471142300da9d58eb0533c&h1=a921c3e004a13795da31fe5c4917984b
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Location&a=refresh&__path=refresh&h=6cde2ab1d2471142300da9d58eb0533c&h1=a921c3e004a13795da31fe5c4917984b",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:03 [warn] 30534#0: *3308583 a client request body is
buffered to a temporary file /tmp/nginx/client_temp/0/14/0000000140 while
sending request to upstream, client: 93.72.48.107, server:
world.mist-game.ru, request: "POST
/?b=4299525&__path=battle&__idlnk=battle&__lnkprtn=0bde4b937a1b23e0762050d981a1b24b&h=f06d26024b03fb60ed4ab5b53594d22f&h1=5967eabf2f67dcf9c0ccc5ffb72cb668
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?b=4299525&__path=battle&__idlnk=battle&__lnkprtn=0bde4b937a1b23e0762050d981a1b24b&h=f06d26024b03fb60ed4ab5b53594d22f&h1=5967eabf2f67dcf9c0ccc5ffb72cb668",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30534#0: *3309232 writev() failed (54:
Connection reset by peer) while sending request to upstream, client:
85.26.233.122, server: world.mist-game.ru, request: "POST
/?ctrl=Battle&a=exitView&__path=exit_battles_view&h=c9165833ad5a3cc6f1e352dca5d2cbc8&h1=bc4603ad81252defa42b6992094ad282
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Battle&a=exitView&__path=exit_battles_view&h=c9165833ad5a3cc6f1e352dca5d2cbc8&h1=bc4603ad81252defa42b6992094ad282",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309251 writev() failed (54:
Connection reset by peer) while sending request to upstream, client:
178.125.170.69, server: world.mist-game.ru, request: "POST
/?ctrl=Location&a=refresh&__path=refresh&h=5bbb356376d6946eaed7df7cc4ac41fd&h1=d13533cd1c18ca300a0e176455d9c664
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Location&a=refresh&__path=refresh&h=5bbb356376d6946eaed7df7cc4ac41fd&h1=d13533cd1c18ca300a0e176455d9c664",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30535#0: *3308345 writev() failed (32: Broken
pipe) while sending request to upstream, client: 95.135.167.243, server:
world.mist-game.ru, request: "POST
/?rs&__path=rs&h=c19c812e5a2f23b7eaf7596ea1d44f12&h1=95c392777791bc5ae60ae449adb106c9
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?rs&__path=rs&h=c19c812e5a2f23b7eaf7596ea1d44f12&h1=95c392777791bc5ae60ae449adb106c9",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309255 writev() failed (54:
Connection reset by peer) while sending request to upstream, client:
92.242.121.254, server: world.mist-game.ru, request: "POST
/?b=4299432&__path=battle&__idlnk=battle&__lnkprtn=a0545dec8ef607a20ef154a82ca20f05&h=56ffab55346f7fe43a9cb427a264ce61&h1=021ff45d67b27baeeb4d4af01787a515
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?b=4299432&__path=battle&__idlnk=battle&__lnkprtn=a0545dec8ef607a20ef154a82ca20f05&h=56ffab55346f7fe43a9cb427a264ce61&h1=021ff45d67b27baeeb4d4af01787a515",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309261 writev() failed (32: Broken
pipe) while sending request to upstream, client: 95.135.167.243, server:
world.mist-game.ru, request: "POST
/?ctrl=Chat&a=onlyMy&__path=chat_onlyforme&h=51ecb5fb1915ed86752a21bbac42d9bd&h1=f398082c8fb066fcea19d0edae19adc6
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Chat&a=onlyMy&__path=chat_onlyforme&h=51ecb5fb1915ed86752a21bbac42d9bd&h1=f398082c8fb066fcea19d0edae19adc6",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"2010/12/11
14:42:04 [error] 30534#0: *3309207 writev() failed (54: Connection reset by
peer) while sending request to upstream, client: 46.70.151.27, server:
world.mist-game.ru, request: "POST
/?ctrl=Char&a=invStored&__path=inventory_stored&__idlnk=inventory_stored&__lnkprtn=6bc918c6ffea3ca73fa3e4a4bac0eaf2&h=f8e3edd6709739bf5dc2fdfc8cab5742&h1=e2dfea894b67581ccf7fe33ccfa80644
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Char&a=invStored&__path=inventory_stored&__idlnk=inventory_stored&__lnkprtn=6bc918c6ffea3ca73fa3e4a4bac0eaf2&h=f8e3edd6709739bf5dc2fdfc8cab5742&h1=e2dfea894b67581ccf7fe33ccfa80644",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309265 writev() failed (54:
Connection reset by peer) while sending request to upstream, client:
78.36.193.8, server: world.mist-game.ru, request: "POST
/?ctrl=Location&a=refresh&__path=refresh&h=d98ba5911a11bb64c9553406ab383678&h1=d93de8abf2e6917fd108de5867d54524
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Location&a=refresh&__path=refresh&h=d98ba5911a11bb64c9553406ab383678&h1=d93de8abf2e6917fd108de5867d54524",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309268 writev() failed (54:
Connection reset by peer) while sending request to upstream, client:
95.110.5.140, server: world.mist-game.ru, request: "POST
/?ctrl=Chat&a=chatList&__path=chat_list&h=92df4f8acb3d45d8b8e964a5b6928d05&h1=cddc100d50f5eb22b131cc52a2659297
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Chat&a=chatList&__path=chat_list&h=92df4f8acb3d45d8b8e964a5b6928d05&h1=cddc100d50f5eb22b131cc52a2659297",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
2010/12/11 14:42:04 [error] 30538#0: *3309270 writev() failed (32: Broken
pipe) while sending request to upstream, client: 86.57.207.30, server:
world.mist-game.ru, request: "POST
/?ctrl=Chat&a=chatList&__path=chat_list&h=07dca26d304b2b7e2d69b16d63705fe2&h1=6684b60dd1e47177e32d768e9ce85b25
HTTP/1.1", upstream: "
http://127.0.0.1:8080/?ctrl=Chat&a=chatList&__path=chat_list&h=07dca26d304b2b7e2d69b16d63705fe2&h1=6684b60dd1e47177e32d768e9ce85b25",
host: "world.mist-game.ru", referrer: "http://world.mist-game.ru/"
... 30-50 записей в секунду ...


Статистика nginx во время нагрузки:
Active connections: 638
server accepts handled requests
 963870 963870 3647402
Reading: 0 Writing: 190 Waiting: 448


Статистика nginx в обычное время:
Active connections: 650
server accepts handled requests
 1130162 1130162 4314128
Reading: 0 Writing: 1 Waiting: 649


Такое чувство, что nginx в этот момент зацикливается и шлёт огромное число
запросов как на cgi так и на прокси.

FreeBSD 8.1 и nginx-0.8.53
----------- следущая часть -----------
Вложение в формате HTML было извлечено…
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20101211/8fb47868/attachment-0001.html>


Подробная информация о списке рассылки nginx-ru