简体   繁体   English

AWS EBS 遇到“504 网关超时”

[英]AWS EBS runs into "504 Gateway Time-out"

I'm new to using AWS EBS and ECS, so please bear with me if I ask questions that might be obvious for others.我刚开始使用 AWS EBS 和 ECS,所以如果我问的问题对其他人来说可能很明显,请耐心等待。 To the issue:针对问题:

I've got a single-container Node/Express application that runs on EBS.我有一个在 EBS 上运行的单容器 Node/Express 应用程序。 The local docker container works as expected.本地 docker 容器按预期工作。 On EBS, I can access one endpoint of the API and get the expected output.在 EBS 上,我可以访问 API 的一个端点并获得预期的输出。 For the second endpoint, which runs longer (around 10-15 seconds) I get no response and run after 60 seconds into a time out: "504 Gateway Time-out".对于运行时间更长(大约 10-15 秒)的第二个端点,我没有收到任何响应,并在 60 秒后运行超时:“504 网关超时”。

I wonder how I would approach debugging this as I can't connect to the container directly?我想知道我将如何调试这个,因为我无法直接连接到容器? Currently there isn't any debugging functionality in the code included either as I'm not sure what the best node approach for a EBS container is - any recommendations are highly appreciated.目前包含的代码中没有任何调试功能,因为我不确定 EBS 容器的最佳节点方法是什么 - 非常感谢任何建议。

Thank you in advance!先感谢您!

You can see the EC2 instances running on EBS in your AWS, and you can choose to give them IP addresses in your EBS options.您可以在 AWS 的 EBS 上看到运行的 EC2 实例,并且可以选择在 EBS 选项中为它们提供 IP 地址。 That will let you SSH directly into them if you need to.如果需要,这将使您可以直接通过 SSH 连接到它们。

Otherwise check the keepAliveTimeout field in your server (the value returned by app.listen() of you're using express).否则请检查服务器中的 keepAliveTimeout 字段(您正在使用 express 的 app.listen() 返回的值)。

I got a decent number of 504s when my Node server timeout was less than my load balancer timeout.当我的 Node 服务器超时小于我的负载平衡器超时时,我得到了相当多的 504。

Your application takes longer than expected (> 60 seconds) to respond, so either nginx or the Load Balancer terminates your request.您的应用程序需要比预期更长的时间(> 60 秒)来响应,因此 nginx 或负载均衡器会终止您的请求。

See my answer here在这里看到我的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM