我目前正在使用 nginx 代理回有 8 个工人的 gunicorn。我正在使用具有 4 个虚拟核心的亚马逊超大实例。当我直接连接到 gunicorn 时,我收到大约 10K 请求/秒。当我从 nginx 提供静态文件时,我收到大约 25 个请求/秒。
但是当我将 gunicorn 放在同一台物理服务器上的 nginx 后面时,我得到大约 5K 请求/秒。我知道 nginx 会有一些延迟,但我认为可能有问题,因为它下降了 50%。有人听说过类似的吗?任何帮助都会很棒!
这是相关的nginx conf:
worker_processes 4;
worker_rlimit_nofile 30000;
events {
worker_connections 5120;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
}
Run Code Online (Sandbox Code Playgroud)
启用站点/默认:
upstream backend {
server 127.0.0.1:8000;
}
server {
server_name api.domain.com ;
location / {
proxy_pass http://backend;
proxy_buffering off;
}
}
Run Code Online (Sandbox Code Playgroud)