Nginx 服务器负载非常高,偶尔崩溃

Nginx 服务器负载非常高,偶尔崩溃

我在 ngnix 服务器上用 Codeigniter 构建了一个活动站点,流量中等。偶尔服务器 CPU 使用率会变得非常高,站点崩溃。运行 top 后,看起来 mysql 导致 CPU 使用率很高。查询缺乏轻微优化,但这会导致 CPU 使用率高的问题吗?还是由于其他配置问题?

服务器详细信息

内存总量:263861736 kB

6 核 CPU

nginx 版本 1.10.3

nginx 配置

    user  nginx;
worker_processes  auto;

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


events {
    worker_connections  1024;
    multi_accept        on;
    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;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";

        gzip_min_length 1000;
        gzip_buffers 4 32k;
        gzip_proxied any;
        gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;

    open_file_cache          max=5000  inactive=20s;
    open_file_cache_valid    30s;
    open_file_cache_min_uses 5;
    open_file_cache_errors   on;

    include /etc/nginx/conf.d/*.conf;
server_tokens off;
}

php fpm 配置

[www]

user = nginx
group = nginx

pm = ondemand
pm.max_children = 100
pm.start_servers = 35
pm.min_spare_servers = 25
pm.max_spare_servers = 50
pm.process_idle_timeout = 10s;

php-fpm 错误日志

[25-Jun-2019 20:16:02] NOTICE: fpm is running, pid 1869
[25-Jun-2019 20:16:02] NOTICE: ready to handle connections
[25-Jun-2019 20:16:02] NOTICE: systemd monitor interval set to 10000ms
[25-Jun-2019 20:16:21] WARNING: [pool www] server reached max_children setting (100), 

consider raising it
[25-Jun-2019 20:17:19] NOTICE: Terminating ...
[25-Jun-2019 20:17:19] NOTICE: exiting, bye-bye!
[25-Jun-2019 20:19:46] WARNING: [pool www] ACL set, listen.owner = 'nginx' is ignored
[25-Jun-2019 20:19:46] WARNING: [pool www] ACL set, listen.group = 'nginx' is ignored

顶部截图 顶部截图

相关内容