Welcome! Log In Create A New Profile

Advanced

Вопрос по memcache+nginx+php-fpm

Rad
June 21, 2012 04:13PM
Добрый вечер,
С nginx работаю не так давно, хотелось бы уточнить некоторые нюансы:
имеется связка (CentOS 6.1) memcache+nginx(1.2.1)+php-fpm. Конфигурация:
......
upstream memcached_backend {
server 127.0.0.1:11211;
keepalive 32;
}
..................
location ~ ^/request/generateXML.*
{
access_log off;
set $memcached_key "page:$request_uri";
#we have upstream memcached_backend to reduce TIME_WAIT
memcached_pass memcached_backend;
default_type text/xml;
error_page 404 405 502 = @cache_miss;
}

location @cache_miss {
access_log off;
rewrite ^.*$ /index.php?what=generateXML&do=generateXML break;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/site/htdocs/$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/site/htdocs;
}

Имеем следующие сценарии:
1)Нет содержимого в мемкеше (error.log in debug mode):
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "X-Powered-By: PHP/5.3.13-1"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Content-Type: text/xml"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Expires: Thu, 21 Jun 2012 19:27:28 GMT"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Cache-Control: no-store, no-cache, must-revalidate"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Cache-Control: post-check=0, pre-check=0"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Pragma: no-cache"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "ETag: "c99222bcc17329301700bc2333212339bb""
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Connection: close"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 0
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header: "Content-Length: 400"
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi parser: 1
2012/06/21 19:27:28 [debug] 8833#0: *1921 http fastcgi header done
2012/06/21 19:27:28 [debug] 8833#0: *1921 xslt filter header
2012/06/21 19:27:28 [debug] 8833#0: *1921 HTTP/1.1 200 OK
Server: nginx/1.2.1
Date: Thu, 21 Jun 2012 19:27:28 GMT
Content-Type: text/xml
Content-Length: 400
Connection: keep-alive
X-Powered-By: PHP/5.3.13-1
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Expires: Thu, 21 Jun 2012 19:27:28 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
ETag: "c99222bcc17329301700bc2333212339bb"

2) Есть содержимое в мемкеше:
2012/06/21 19:27:29 [debug] 8833#0: *1921 http upstream request: "/request/generateXML?mon=6&week=2"
2012/06/21 19:27:29 [debug] 8833#0: *1921 http upstream process header
2012/06/21 19:27:29 [debug] 8833#0: *1921 recv: fd:6 469 of 4096
2012/06/21 19:27:29 [debug] 8833#0: *1921 memcached: "VALUE page:/request/generateXML?mon=6&week=2 0 400"
2012/06/21 19:27:29 [debug] 8833#0: *1921 xslt filter header
2012/06/21 19:27:29 [debug] 8833#0: *1921 HTTP/1.1 200 OK
Server: nginx/1.2.1
Date: Thu, 21 Jun 2012 19:27:29 GMT
Content-Type: text/xml
Content-Length: 400
Connection: keep-alive

Вопросы:
1. Я так понимаю режутся заголовки:
- можно решить сторонним модулем (чтоб хранить заголовок)
- использовать fastcgi_pass_header, но почему-то он у меня не работает.

2. Чтоб установить Connection: close нужно в локейшене:
keepalive_timeout 0;
Однако в таком случае у меня поднимается значение TIME_WAIT до 21 000, и падает показатель Active Connections:
Active connections: 1976
server accepts handled requests
1313402 1313402 18510553
Reading: 10 Writing: 4 Waiting: 1962
Connection closed by foreign host.

если же использовать Connection: keep-alive, то понятное дело, Active connections поднимается до: 6976, а значение TIME_WAIT падает до 1000.

Просьба поправить меня в моих суждениях и/или ошибках. А также, что будет правильнее keep-alive (с Waiting > 5000, но TIME_WAIT<2000) или close (с Waiting < 2000, но TIME_WAIT>21000)

PS. Некоторый тюнинг по TIME_WAIT на уровне OS делал.

Заранее спасибо
Subject Author Posted

Вопрос по memcache+nginx+php-fpm

Rad June 21, 2012 04:13PM

Re: Вопрос по memcache+nginx+php-fpm

Maxim Dounin June 22, 2012 04:02AM

Re: Вопрос по memcache+nginx+php-fpm

Rad June 22, 2012 04:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready