【发布时间】:2022-07-27 23:30:41
【问题描述】:
我有一项在 AWS-ECS 上工作的服务,它有两项任务:一项用于 uswgi,一项用于 nginx。使用 uswgi,我提供了一个有时需要超过 60 秒才能处理的 API。对于超过 60 秒的进程,我得到一个超时错误作为响应。我试图在 nginx 配置和 AWS-ELB 的目标组中增加超时,但没有任何效果......这是我的配置:
server {
listen ${LISTEN_PORT};
client_header_timeout 600s;
client_body_timeout 600s;
uwsgi_read_timeout 600s;
proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
location /static {
alias /vol/static;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, OPTIONS, HEAD, DELETE';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
location / {
uwsgi_pass ${APP_HOST}:${APP_PORT};
include /etc/nginx/uwsgi_params;
client_max_body_size 300M;
client_body_buffer_size 300M;
client_body_timeout 600s;
uwsgi_read_timeout 600s;
}
location /elb-status {
access_log off;
client_body_timeout 600s;
uwsgi_read_timeout 600s;
return 200;
}
}
以及 AWS-EBL 中目标组中的健康检查:
- Unhealthy threshold: 2 consecutive health check failures
- Timeout: 5 seconds
- Interval: 100 seconds
- Success codes: 200
这很奇怪,因为进程在超时响应后继续运行,我在 nginx 日志或目标组监控部分没有收到任何错误。我确定我错过了一些东西,因为超时错误正好显示在 1 分钟,请检查来自前端的响应:
【问题讨论】:
标签: nginx amazon-ecs uwsgi nginx-config aws-elb