簡體   English   中英

nginx + php-fpm配置。 服務器停頓

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

運行每天有14萬次頁面瀏覽量的服務器(分析)。 php-fpm進程每個大約花費10-12M。
服務器有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;
}

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

通常,該服務器可以同時運行500個用戶(再次使用實時Google Analytics(分析)來獲取此估算值)就可以正常運行,但在用戶數量不多(75-100個同時用戶)的情況下會停滯。

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

我並不是說這是最好的設置,但是它對我們有用。

我使用nginx設置更新的幾件事是:

worker_connections ,我相信瀏覽器會為每個請求打開兩個連接,因此從技術上講,每個請求您沒有1024個可用連接,而您有512個,因此可以將其更改為2048個。

我還只在您考慮將寫入時間保持為低時就將錯誤日志文件參數更改為“ info”,因此我將其從“ warn”更改為“ info”。

如果您想保留訪問日志,則可以減少它添加的整個日志。

可能值得看一下您的母版nginx.conf,並且您的配置可能會被此文件覆蓋並重新設置為默認值。

我從一大堆清單中做了兩件事,但是這篇文章很棒- 鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM