<分区>
我将 Nginx 用作 RPS,并且遇到服务器无法处理超过 ~ 100 个请求/秒的问题。如果单个 IP 发送那么多请求,Nginx 将为所有人提供 502 错误。
这是我的。
具有此规范的专用机器,
100 mbps(双向)。 双核处理器 5 GB 内存 Windows 服务器 2008 R2
Apache、PHP(作为模块)和 MySQL 在后台处理动态内容。 Nginx 在前面并将请求传递给 Apache。
服务器上的每个页面都是动态生成和优化的,没有 MySQL 负载等......每个页面大小都在 50KB 以下。
响应时间/加载时间低于 0.6 秒。
所以一切都很顺利,直到有人打开任何软件并向服务器发送请求,当请求速率约为 100req/s 时,它开始发送 502 错误。请求永远不会到达 Apache。所以这不是 Apache 的问题。
那台服务器不会处理更多吗?
这是 Nginx CONF 的样子,
http {
include 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 K:/logs/nginx/access.log main;
sendfile off;
server_tokens off;
keepalive_timeout 65;
server_names_hash_bucket_size 64;
client_max_body_size 50m;
server {
listen 80;
server_name www.domain.com;
proxy_pass_header Server;
root K:/website/domain.com/;
index index.html index.htm index.php;
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
## send request back to Apache ##
location / {
proxy_pass http://127.0.0.1:8080;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
感谢任何帮助和建议。