【问题标题】:Unable to increase the timeout on AWS Elastic Beanstalk无法增加 AWS Elastic Beanstalk 的超时时间
【发布时间】:2020-12-23 14:38:12
【问题描述】:

我正在尝试增加 Amazon Elastic Beanstalk 上的超时,但我仍然收到 504 网关超时。

这是我到目前为止所做的:

.ebextensions/timeouts.config:

option_settings:
  - namespace: aws:elb:policies
    option_name: ConnectionSettingIdleTimeout
    value: 940
  - namespace: aws:elbv2:loadbalancer
    option_name: IdleTimeout
    value: 940

files:
  "/etc/nginx/conf.d/nginx.timeouts.conf":
      mode: "644"
      owner: "root"
      group: "root"
      content: |
        client_header_timeout   5;
        client_body_timeout     10;
        send_timeout            940;
        proxy_connect_timeout   2;
        proxy_read_timeout      940;
        proxy_send_timeout      10;

container_commands:
  01_update_nginx:
    command: "sudo sed -i 's/keepalive_timeout  65;/keepalive_timeout  940;/g' /etc/nginx/nginx.conf"
  02_restart_nginx:
    command: "sudo service nginx restart"

过程文件:

web: gunicorn --bind :8000 --workers 10 --timeout 935 --graceful-timeout 935 main:app

尽管如此,我仍然在 60.1 秒后收到“504 网关超时”。

我缺少什么应该使它起作用?

【问题讨论】:

  • 理论上你已经得到了那里需要的东西。在部署配置更改后,您是否检查过 ELB 超时值已更改?但是什么需要这么长时间?
  • 您使用的是基于 Amazon Linux 1 还是 2 的 EB 平台?
  • 我注意到您的 sed 命令替换了默认超时 65,但您观察到的超时为 60,这表明您可能正在寻找要替换的错误字符串?
  • @Marcin 我正在使用 Amazon Linux 2。

标签: amazon-web-services amazon-elastic-beanstalk


【解决方案1】:

您的 /etc/nginx/conf.d/nginx.timeouts.conf 不起作用,因为这是基于 Amazon Linux 1 (AL1) 的 EB 平台的有效文件。但是,正如 cmets 所证实的,您使用的是 AL2。

对于 AL2,nginx 设置应在 .platform/nginx/conf.d/ 中,而不是在 .ebextentions 中,如“反向代理配置”部分中的 docs 所示。

因此,您可以尝试使用以下内容创建以下 .platform/nginx/conf.d/myconfig.conf 文件:

client_header_timeout   5;
client_body_timeout     10;
send_timeout            940;
proxy_connect_timeout   2;
proxy_read_timeout      940;
proxy_send_timeout      10;

【讨论】:

  • 确实如此!我非常喜欢这个,而不是在部署时重新启动 Nginx!谢谢!
  • 带 Corretto 的 AM2 使用 .platform 配置路径,但 .ebextensions 对我来说适用于 在 64 位 Amazon Linux/2.10.2 上运行的 Java 8
猜你喜欢
  • 2015-06-03
  • 2018-08-14
  • 2020-06-28
  • 2021-03-16
  • 2021-06-27
  • 1970-01-01
  • 2014-08-21
  • 2019-06-30
  • 2019-06-29
相关资源
最近更新 更多