如何解决等待请求时 Nginx 错误 recv() failed (14: Bad address)
我有一个 Nginx + flask + gunicorn 应用程序,我将其 dockerize 并将其放置在 AWS EC2 实例中。 它运行良好,我的负载测试达到了 4000 TPS。
如果我将相同的应用程序部署到网络负载均衡器后面的 ECS,我会遇到以下错误:
[alert] 66#0: *3501872 recv() Failed (14: Bad address) while waiting for request,client: *IP*,server: 0.0.0.0:8080
[error] 124#0: *6027194 connect() to unix:/tmp/gunicorn_predictor.sock Failed (11: Resource temporarily unavailable) while connecting to upstream,server:,request: “POST /invocations HTTP/1.1”,upstream: “http://unix:/tmp/myapp.sock:/invocations”,host: “url:80”
这是我的 Nginx 配置:
worker_processes 96; #number of cpu cores
daemon off; # Prevent forking
pid /tmp/Nginx.pid;
error_log /var/log/Nginx/error.log;
worker_rlimit_nofile 65535;
events {
worker_connections 665;
use epoll;
multi_accept on;
}
http {
include /path/conf/mime.types;
default_type application/octet-stream;
access_log off;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
reset_timedout_connection on;
upstream gunicorn_interceptor {
server unix:/tmp/gunicorn_interceptor.sock;
}
keepalive_timeout 3600s;
keepalive_requests 500000;
upstream gunicorn_predictor {
server unix:/tmp/gunicorn_predictor.sock;
keepalive 512;
}
server {
listen 8080 deferred;
client_max_body_size 5m;
proxy_read_timeout 3600s;
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
location ~ ^/(ping) {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://gunicorn_interceptor;
}
location ~ ^/(invocations) {
proxy_buffers 8 24k;
proxy_buffer_size 2k;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://gunicorn_predictor;
}
location / {
return 404 "{}";
}
}
}
是否与 somaxconn
之类的内核参数有关?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。