为什么php-fpm(nginx)占用大量内存?

时间:2014-12-23 05:24:03

标签: performance nginx amazon-ec2 server php

我的服务器详细信息位于屏幕截图中,这是来自AWS Amazon EC2的最佳专用服务器。 enter image description here

但有一点我注意到php-fpm占用内存10.9 GB,占总数的70%。它不应该像那样占用很多记忆。我在nginx.conf文件中做错了什么?

user  nginx;
worker_processes  8;
worker_rlimit_nofile 100000;
pid        /var/run/nginx.pid;


events {
    worker_connections  3000;
    use epoll;
    multi_accept on;
}




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

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;



    open_file_cache max=20000 inactive=30s;
    open_file_cache_valid 60s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
    tcp_nodelay on;
    # keepalive_requests 300;
    # reset_timedout_connection on;
    sendfile        on;
    tcp_nopush     on;
    keepalive_timeout  30;
    gzip  on;
    gzip_min_length 256;
    gzip_comp_level 3;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

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

}

1 个答案:

答案 0 :(得分:0)

我发现降低它的一种方法是,在php-fpm配置文件中将pm = dynamic的值更改为pm = ondemand。对于php 7,路径为/etc/php-fpm.d/www.conf。不要忘记更改后重新启动php-fpm。