Gunicorn + Nginx - 连接到上游时资源暂时不可用

pra*_*tik 5 django nginx supervisord gunicorn amazon-elastic-beanstalk

我们正在使用 Gunicorn + Supervisor + nginx 在 beanstalk 上使用 docker 环境运行 django 应用程序

问题是主管显示 Gunicorn 已启动,但所有请求均失败,并显示来自 nginx 的 502 响应代码。即使实例上没有流量,Gunicorn 进程也不会恢复。

理想情况下,我认为主管应该重新启动 Gunicorn 进程,因为它无法成功响应任何请求。

负载:每分钟/实例约 1700 个请求 - c6a.large 实例

server_tokens off;

upstream wsgi_server {
  # fail_timeout=0 means we always retry an upstream even if it failed
  # to return a good HTTP response (in case the Unicorn master nukes a
  # single worker for timing out).

  server unix:/run/django_app.sock fail_timeout=0;
}

server {
  location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-Protocol $http_x_forwarded_proto;
      proxy_redirect off;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Scheme $scheme;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_connect_timeout 60s;
      proxy_read_timeout 60s;
      proxy_pass http://wsgi_server;
  }
}
Run Code Online (Sandbox Code Playgroud)
2022/10/10 12:35:26 [error] 21#21: *728396 connect() to unix:/run/django_app.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 172.31.53.68, server: *.service.vpc, request: "GET /user/ HTTP/1.1", upstream: "http://unix:/run/django_app.sock:/user/", host: "service.vpc"
Run Code Online (Sandbox Code Playgroud)

另外,如何调试挂起的gunicorn工人以找出问题到底出在哪里?