Re: nginx потребляет процессор больше чем php-fpm

Александр Усов ooshro на ooshro.org
Чт Мар 3 16:24:37 MSK 2011


При наличии проблемы нужно не гадать и тыкаться, а диагностировать.

Для анализа использования памяти, можно использовать pmap. Запускаешь pmap
на первом сервере и на втором, и анализируй карты памяти. Пример:

pmap `pgrep nginx`
1208:   nginx: master process /usr/sbin/nginx
0000000000400000    592K r-x--  /usr/sbin/nginx
0000000000693000      4K r----  /usr/sbin/nginx
0000000000694000     64K rw---  /usr/sbin/nginx
00000000006a4000     56K rw---    [ anon ]
00000000021e7000    268K rw---    [ anon ]
....
00007f7bc6946000      4K r----  /lib/ld-2.11.1.so
00007f7bc6947000      4K rw---  /lib/ld-2.11.1.so
00007f7bc6948000      4K rw---    [ anon ]
00007fff88492000     84K rw---    [ stack ]
00007fff885ff000      4K r-x--    [ anon ]
ffffffffff600000      4K r-x--    [ anon ]
 total            17420K

По процесору, для начала можно пыпытатся strace -cfp PID:

strace -cfp 1209
Process 1209 attached - interrupt to quit
^CProcess 1209 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 67.36    0.000097           1        83           writev
 19.44    0.000028           1        42           write
 13.19    0.000019           0        54           epoll_ctl
  0.00    0.000000           0        43           close
  0.00    0.000000           0        48           ioctl
  0.00    0.000000           0       639       285 readv

Дальше можно google-perftool, OProfile и т.д.

3 марта 2011 г. 16:46 пользователь Denis Kot <denis.kot на gmail.com> написал:

> Перенес сайт на новый сервер. На старом стоял CentOS и nginx + php-fpm
> 5.2.11 собранные из сырцов. На новом сервер Gentoo и nginx естественно
> собран из сырцов так же.
> На новом сервере nginx постоянно находится в самом верху вывода команды
> top.
>
> Старый сервер:
> # nginx -V
> nginx version: nginx/0.8.29
> TLS SNI support disabled
> configure arguments: --prefix=/usr --conf-path=/etc/nginx/nginx.conf
> --http-log-path=/var/log/nginx/access_log
> --error-log-path=/var/log/nginx/error_log
> --pid-path=/var/run/nginx.pid
> --http-client-body-temp-path=/var/tmp/nginx/client
> --http-proxy-temp-path=/var/tmp/nginx/proxy
> --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --with-md5-asm
> --with-md5=/usr/include --with-sha1-asm --with-sha1=/usr/include
> --with-http_addition_module --with-http_realip_module
> --with-http_ssl_module --with-http_perl_module
> --with-http_stub_status_module --without-mail_pop3_module
> --without-mail_smtp_module --without-mail_imap_module
>
> PHP 5.2.11
>
> Новый сервер:
> # nginx -V
> nginx version: nginx/0.8.53
> TLS SNI support enabled
> configure arguments: --prefix=/usr --sbin-path=/usr/sbin/nginx
> --conf-path=/etc/nginx/nginx.conf
> --error-log-path=/var/log/nginx/error_log
> --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock
> --user=nginx --group=nginx --with-cc-opt=-I/usr/include
> --with-ld-opt=-L/usr/lib --http-log-path=/var/log/nginx/access_log
> --http-client-body-temp-path=/var/tmp/nginx/client
> --http-proxy-temp-path=/var/tmp/nginx/proxy
> --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi
> --http-scgi-temp-path=/var/tmp/nginx/scgi
> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --with-file-aio
> --with-aio_module --with-pcre --without-http_auth_basic_module
> --without-http_autoindex_module --without-http_browser_module
> --without-http_empty_gif_module --without-http_geo_module
> --without-http_limit_req_module --without-http_limit_zone_module
> --without-http_map_module --without-http_memcached_module
> --without-http_referer_module --without-http_scgi_module
> --without-http_ssi_module --without-http_split_clients_module
> --without-http_userid_module --without-http_uwsgi_module
> --with-http_addition_module --with-http_gzip_static_module
> --with-http_realip_module --with-http_stub_status_module
> --with-http_realip_module --with-http_ssl_module
> --without-mail_imap_module --without-mail_pop3_module
> --without-mail_smtp_module
>
> PHP 5.3.5-pl0-gentoo
>
> Конфиг nginx перенесен со старого сервера без правок.
>
> Вывод top такой:
>  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
> 19970 nginx     20   0  124m  36m  864 S   28  0.9  18:02.17 nginx
> 19969 nginx     20   0  129m  41m  864 R   26  1.0  19:09.88 nginx
> 24247 nginx     20   0  216m  16m   9m R   15  0.4   0:03.00 php-fpm
> 24289 nginx     20   0  215m  12m 7552 R    9  0.3   0:00.99 php-fpm
> 24262 nginx     20   0  218m  25m  18m R    9  0.6   0:02.14 php-fpm
>
> Иногда CPU у nginx доходит до 50%
>
>
> Как посмотреть чем занят nginx?
> Может ли влиять TLS SNI support enabled/disabled?
>
> Denis Kot
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru на nginx.org
> http://nginx.org/mailman/listinfo/nginx-ru
>
----------- следущая часть -----------
Вложение в формате HTML было извлечено&hellip;
URL: <http://nginx.org/pipermail/nginx-ru/attachments/20110303/b5648f4e/attachment-0001.html>


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