简体   繁体   English

nginx + php-fpm配置。 服务器停顿

[英]nginx + php-fpm configuration. Server stalls

Running a server with 140 000 page views a day (analytics). 运行每天有14万次页面浏览量的服务器(分析)。 php-fpm processes go for about 10-12M each. php-fpm进程每个大约花费10-12M。
Servers got 10G ram, mysql goes for 1.2G-1.6G 服务器有10G内存,MySQL为1.2G-1.6G

Configuration looks like this: 配置看起来像这样:

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;
}

php-fpm like this: php-fpm像这样:

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 = /

Typically the server can run just fine with 500 simultaneous users (again, real time google analytics used to get this estimate) but stall at times where users are not that many (75-100 simultaneous users). 通常,该服务器可以同时运行500个用户(再次使用实时Google Analytics(分析)来获取此估算值)就可以正常运行,但在用户数量不多(75-100个同时用户)的情况下会停滞。

The configuration is done by my ISP, who i trust, but i still would like to know if the configuration makes sense. 配置由我信任的ISP完成,但是我仍然想知道配置是否合理。

I am not saying this is the best setup however it works for us. 我并不是说这是最好的设置,但是它对我们有用。

A few things I updated with our nginx setup are: 我使用nginx设置更新的几件事是:

The worker_connections , I believe that a browser opens two connections per request so you don't technically have 1024 available connections per request you have 512 so maybe change it to 2048. worker_connections ,我相信浏览器会为每个请求打开两个连接,因此从技术上讲,每个请求您没有1024个可用连接,而您有512个,因此可以将其更改为2048个。

I also changed the error log file param to "info" only as you have think about write times to keep the I/O low, So I changed it from "warn" to "info". 我还只在您考虑将写入时间保持为低时就将错误日志文件参数更改为“ info”,因此我将其从“ warn”更改为“ info”。

If you want to keep the access log maybe slim down the log entires it adds. 如果您想保留访问日志,则可以减少它添加的整个日志。

It might be worth looking at your master nginx.conf aswell you might have configs being overwritten by this file and being set back to default. 可能值得看一下您的母版nginx.conf,并且您的配置可能会被此文件覆盖并重新设置为默认值。

Just two little things I did from a big list I went through, however this article is great - link 我从一大堆清单中做了两件事,但是这篇文章很棒- 链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM