Configuration nginx+;php fpm配置。服务器暂停

Configuration nginx+;php fpm配置。服务器暂停,configuration,nginx,php,Configuration,Nginx,Php,每天运行140000次页面浏览的服务器(分析)。 php fpm进程每一个大约有1000-1200万个。 服务器有10G内存,mysql的内存为1.2G-1.6G 配置如下所示: nginx user nginx; worker_processes 4; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; }

每天运行140000次页面浏览的服务器(分析)。 php fpm进程每一个大约有1000-1200万个。
服务器有10G内存,mysql的内存为1.2G-1.6G

配置如下所示:

nginx

user  nginx;
worker_processes  4;

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


events {
    worker_connections  1024;
}


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;
     access_log off;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  10;

    client_max_body_size 20M;

        server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
user = webadmin
group = webadmin
pm = dynamic
pm.max_children = 900
pm.start_servers = 900
pm.min_spare_servers = 200
pm.max_spare_servers = 900
pm.max_requests = 500
chdir = /
php fpm如下所示:

nginx

user  nginx;
worker_processes  4;

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


events {
    worker_connections  1024;
}


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;
     access_log off;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  10;

    client_max_body_size 20M;

        server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
user = webadmin
group = webadmin
pm = dynamic
pm.max_children = 900
pm.start_servers = 900
pm.min_spare_servers = 200
pm.max_spare_servers = 900
pm.max_requests = 500
chdir = /
通常情况下,服务器可以在同时有500个用户的情况下正常运行(同样,实时google analytics用于获得此估计值),但在用户不多的情况下(75-100个同时用户)会暂停运行


配置由我的ISP完成,我信任他,但我仍然想知道配置是否合理。

我不是说这是最好的设置,但它适合我们

我用我们的nginx设置更新了以下几点:

对于worker\u connections,我认为浏览器会为每个请求打开两个连接,因此从技术上讲,每个请求没有1024个可用连接,所以可能会将其更改为2048

我还将错误日志文件参数更改为“info”,只是因为您考虑了保持低I/O的写入时间,所以我将其从“warn”更改为“info”

如果您想保留访问日志,可以缩小它添加的日志实体

可能值得一看您的主nginx.conf,您的配置可能会被此文件覆盖并设置回默认值


在我浏览过的一个大列表中,我只做了两件小事,不过这篇文章很棒-

谢谢RBS。我特别想知道php fpm配置,因为php fpm进程占用了我们所有的内存。max_children=900智能吗?嘿,我在运行ubuntu,所以可能不一样,但我通过apt安装了ab,然后安装了htop,这样我可以看到内存使用率逐渐上升,然后让ab发送一堆请求并跟踪内存使用情况,因为我设置了max_children,还有等待接收进程的孩子,我想说的是,获取一些基准测试工具并进行测试,直到获得完美的设置。这有用吗?