Elastic Beanstalk Worker 的 SQS 守护进程在 1 分钟后获得 504 网关超时
Elastic Beanstalk Worker's SQS daemon getting 504 gateway timeout after 1 minute
我有一个 Elastic Beanstalk worker,它一次只能 运行 一个任务,而且这样做需要一些时间(从几分钟到,希望不到 30 分钟),所以我'我在 SQS 上排队我的任务。
在我的工作器配置中,我有:
HTTP connections: 1
Visibility timeout: 3600
Error visibility timeout: 300
(On "Advanced")
Inactivity timeout: 1800
问题是似乎有 1 分钟的超时(在 nginx 上?)覆盖 "Inactivity timeout",返回 504(网关超时)。
这是我可以在 aws-sqsd.log 文件中找到的内容:
2016-02-03T16:16:27Z init: initializing aws-sqsd 2.0 (2015-02-18)
2016-02-03T16:16:27Z start: polling https://sqs.eu-central-1.amazonaws.com/855381918026/jitt-publisher-queue
2016-02-03T16:23:36Z message: sent to %[http://localhost:80]
2016-02-03T16:24:36Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (1) 504 - 60.006
2016-02-03T16:28:54Z message: sent to %[http://localhost:80]
2016-02-03T16:29:54Z http-err: 1b7514d3-689a-4e8b-a569-5ef1ac32ed0c (1) 504 - 60.029
2016-02-03T16:29:54Z message: sent to %[http://localhost:80]
2016-02-03T16:29:54Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (2) 500 - 0.006
2016-02-03T16:33:49Z message: sent to %[http://localhost:80]
2016-02-03T16:34:49Z http-err: 3a43e80f-a8d3-46b2-b2a0-9d898ad4f2a6 (1) 504 - 60.023
2016-02-03T16:34:54Z message: sent to %[http://localhost:80]
2016-02-03T16:34:54Z http-err: 1b7514d3-689a-4e8b-a569-5ef1ac32ed0c (2) 500 - 0.004
2016-02-03T16:34:54Z message: sent to %[http://localhost:80]
2016-02-03T16:34:54Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (3) 500 - 0.003
2016-02-03T16:39:49Z message: sent to %[http://localhost:80]
2016-02-03T16:40:49Z http-err: 3a43e80f-a8d3-46b2-b2a0-9d898ad4f2a6 (2) 504 - 60.019
这里有些事情是有意义的,比如每条消息从 504/500 时间到任务再次重新发送给工作人员所花费的 5 分钟延迟(这与 [ 的 300 秒配置相匹配) =29=]).
那 500 个代码符合我当前的逻辑:如果还有东西,工作人员会通过抛出 500 来拒绝任务 运行ning。
我看到很多关于设置 Load Balancer 连接超时设置的答案,但是,由于这是一个从 SQS 队列中拉取消息的 worker,所以没有 Load Balancer。
知道我应该如何覆盖 1 分钟超时设置吗?
由于我有时间对此进行了更好的调查,解决方案是添加一个配置代理超时设置的 ebextension:
files:
"/etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy-timeout.conf":
mode: "000644"
owner: root
group: root
content: |
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
commands:
"00nginx-create-proxy-timeout":
command: "if [[ ! -h /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy-timeout.conf ]] ; then ln -s /etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy-timeout.conf /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy-timeout.conf ; fi"
我有一个 Elastic Beanstalk worker,它一次只能 运行 一个任务,而且这样做需要一些时间(从几分钟到,希望不到 30 分钟),所以我'我在 SQS 上排队我的任务。
在我的工作器配置中,我有:
HTTP connections: 1
Visibility timeout: 3600
Error visibility timeout: 300
(On "Advanced")
Inactivity timeout: 1800
问题是似乎有 1 分钟的超时(在 nginx 上?)覆盖 "Inactivity timeout",返回 504(网关超时)。
这是我可以在 aws-sqsd.log 文件中找到的内容:
2016-02-03T16:16:27Z init: initializing aws-sqsd 2.0 (2015-02-18)
2016-02-03T16:16:27Z start: polling https://sqs.eu-central-1.amazonaws.com/855381918026/jitt-publisher-queue
2016-02-03T16:23:36Z message: sent to %[http://localhost:80]
2016-02-03T16:24:36Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (1) 504 - 60.006
2016-02-03T16:28:54Z message: sent to %[http://localhost:80]
2016-02-03T16:29:54Z http-err: 1b7514d3-689a-4e8b-a569-5ef1ac32ed0c (1) 504 - 60.029
2016-02-03T16:29:54Z message: sent to %[http://localhost:80]
2016-02-03T16:29:54Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (2) 500 - 0.006
2016-02-03T16:33:49Z message: sent to %[http://localhost:80]
2016-02-03T16:34:49Z http-err: 3a43e80f-a8d3-46b2-b2a0-9d898ad4f2a6 (1) 504 - 60.023
2016-02-03T16:34:54Z message: sent to %[http://localhost:80]
2016-02-03T16:34:54Z http-err: 1b7514d3-689a-4e8b-a569-5ef1ac32ed0c (2) 500 - 0.004
2016-02-03T16:34:54Z message: sent to %[http://localhost:80]
2016-02-03T16:34:54Z http-err: 1444d1ba-ecb5-46f8-82d6-d0bf19b91fad (3) 500 - 0.003
2016-02-03T16:39:49Z message: sent to %[http://localhost:80]
2016-02-03T16:40:49Z http-err: 3a43e80f-a8d3-46b2-b2a0-9d898ad4f2a6 (2) 504 - 60.019
这里有些事情是有意义的,比如每条消息从 504/500 时间到任务再次重新发送给工作人员所花费的 5 分钟延迟(这与 [ 的 300 秒配置相匹配) =29=]).
那 500 个代码符合我当前的逻辑:如果还有东西,工作人员会通过抛出 500 来拒绝任务 运行ning。
我看到很多关于设置 Load Balancer 连接超时设置的答案,但是,由于这是一个从 SQS 队列中拉取消息的 worker,所以没有 Load Balancer。
知道我应该如何覆盖 1 分钟超时设置吗?
由于我有时间对此进行了更好的调查,解决方案是添加一个配置代理超时设置的 ebextension:
files:
"/etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy-timeout.conf":
mode: "000644"
owner: root
group: root
content: |
proxy_connect_timeout 3600;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
send_timeout 3600;
commands:
"00nginx-create-proxy-timeout":
command: "if [[ ! -h /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy-timeout.conf ]] ; then ln -s /etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy-timeout.conf /etc/nginx/sites-enabled/elasticbeanstalk-nginx-docker-proxy-timeout.conf ; fi"