duan00529 2013-01-09 14:32 采纳率: 100%
浏览 34

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

Running a server with 140 000 page views a day (analytics). php-fpm processes go for about 10-12M each.
Servers got 10G ram, mysql goes for 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:

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).

The configuration is done by my ISP, who i trust, but i still would like to know if the configuration makes sense.

  • 写回答

1条回答 默认 最新

  • donglv6960 2013-01-09 16:09
    关注

    I am not saying this is the best setup however it works for us.

    A few things I updated with our nginx setup are:

    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.

    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".

    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.

    Just two little things I did from a big list I went through, however this article is great - link

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值