运行一个每天有 140 000 次页面浏览量的服务器(分析)。每个 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 个同时用户的情况下正常运行(同样,实时谷歌分析用于获得此估计值)但有时会在用户不是很多(75-100 个同时用户)时停止。
配置由我信任的 ISP 完成,但我仍然想知道配置是否有意义。