AWS Fargate-应用程序负载平衡器(ELB)显示不健康的目标,并显示错误“运行状况检查失败,并显示以下代码:[502]"; [英] AWS Fargate - Application load balancer(ELB) shows unhealthy targets with error "Health checks failed with these codes: [502]"

查看:171
本文介绍了AWS Fargate-应用程序负载平衡器(ELB)显示不健康的目标,并显示错误“运行状况检查失败,并显示以下代码:[502]";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在端口3000上运行,并且Web上下文是/app,因此" http://host:3000/app/index.html "成功返回本地运行该应用程序的index.html页面.

My app is running on port 3000 and web context is /app, so "http://host:3000/app/index.html" successfully returns index.html page running the app locally.

负载均衡器(公共)在端口80上侦听并将流量转发到端口3000上的目标.

Load balancer(public) listens on port 80 and forwards traffic to targets on port 3000.

AWS Fargate-任务定义具有映射到端口3000的主机和容器端口.-任务显示为正在运行"和状态为健康",但由于ELB运行状况而最终停止检查失败.而且我能够在Cloud Watch中看到我的应用程序启动日志(任务->日志).-群集服务的安全组正在自定义tcp端口3000上接收入站流量.

AWS Fargate - task definition has host and container port mapped to port 3000. - tasks are shown as RUNNING and status HEALTHY but eventually stops because ELB health checks fails. And i am able to see my app start up logs in cloud watch (tasks -> logs). - Security group of cluster service is receiving inbound traffic on custom tcp port 3000.

我已尝试通过更新TargetGroup运行状况检查以将路径用作"/","/app"和"/app/index.html",但这也不起作用.

I have tried by updating TargetGroup health checks to use paths as "/", "/app" and "/app/index.html" but this does not work either.

推荐答案

首先验证:

  • 您的应用程序在容器错误内启动.
  • 您的安全配置允许ECS与ELB之间进行通信.
  • 您的健康检查指向正确的道路.

现在该看看ELB日志了,您可以按照以下

It's time to take a look at the ELB logs, you can enable them following this tutorial.

借助ECS服务日志,ECS任务日志和ELB日志,您可以确定应用程序启动需要多长时间.运行后,将ECS服务宽限期配置为该值.

With the ECS Service logs, ECS task logs and ELB logs you can determine how long takes for your application to be up & running, once you know that, configure the ECS Service grace period to that value.

一旦宽限期足够长以至于可以进行前面解释的操作,您的应用程序将通过运行状况检查.

Once your grace period is big enough to allow the previously explained to happen, your application will pass the health checks.

例如,在我们的示例中,一个Spring Boot应用程序在EC2实例中启动大约需要20秒,因此在ECS Fargate服务上可能需要3分钟以上的时间才能到达,因此我们将宽限期设置为240秒就解决了问题.

这篇关于AWS Fargate-应用程序负载平衡器(ELB)显示不健康的目标,并显示错误“运行状况检查失败,并显示以下代码:[502]";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆