1

My Server has the following Specs

CPU: 6 Cores Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
RAM: 32 GB

I have a problem with nginx+php-fpm. They are taking too many resources for an unknown reason. Even if i restart the nginx + php-fpm the start up processes will use many resources.

My nginx Config is the following:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

worker_rlimit_nofile 300000;
events {
    worker_connections  6000;
    use epoll;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;


#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

include /etc/nginx/conf.d/*.conf;

}

My php-fpm pool config is the following

[www]
user = nginx
group = nginx
listen = /var/run/php5-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.allowed_clients = 127.0.0.1
pm = ondemand
pm.max_children = 1500;
pm.process_idle_timeout = 5;
chdir = /
security.limit_extensions = .php

I'm using on pm.ondemand since my website has to support many concurrent connections at the same time and i was unable to to it with dynamic/static.

I guess this isnt the problem because as i said earlier when i restart nginx+php-fpm at the same time, they are taking too much resources without any request.

Here is the screenshot with the CPU Usage

http://s28.postimg.org/v54q25zod/Untitled.png
user3393046
  • 121
  • 2
  • 10
  • 1
    What do you mean by "too many resources"? – Michael Hampton Jun 08 '14 at 12:18
  • Look the image. it uses a lot of CPU – user3393046 Jun 08 '14 at 13:35
  • I didn't see a lot of CPU being used in your image. Please be more specific. – Michael Hampton Jun 08 '14 at 13:37
  • Mate, its 33.0% and 34.6% for just 2 php-fpm processes! And the normal is 1% or less. I have some other servers that uses only 0-1% and 0% memory. Here my CPU Is full due to these processes – user3393046 Jun 08 '14 at 13:55
  • OK, then you need to look at your application. – Michael Hampton Jun 08 '14 at 14:12
  • As i said with no visitors nothing, when i just restart nginx + php-fpm the 2 php fpm processes are going to 33 and 34% instant with no traffic at all. – user3393046 Jun 08 '14 at 14:40
  • If you stop nginx, and then restart php-fpm without starting nginx, does the php-fpm load still increase to 33% and 34% instantly? – Tero Kilkanen Jun 08 '14 at 15:52
  • When i close Nginx, i only have one process: php-fpm: master process (/etc/php5/fpm/php-fpm.conf) and yes the cpu load now goes to normal. So what is nginx doing? – user3393046 Jun 08 '14 at 17:07
  • there is nothing wrong with your image, to me 33% is pretty normal. depends on your application... it could be 60% or 90%, nothing wrong with it too.. use cache - varnish, redis, memcached, apc, etc!! - btw the most important is load average, if it goes above 7, then you need to worry!! – ADM Jun 08 '14 at 18:10

0 Answers0