简体   繁体   English

目标可访问但 ECS 服务日志显示请求超时

[英]Target accessible but ECS service logs says Request timed out

I am just getting started with ECS.我刚刚开始使用 ECS。 I created a docker image which contains a simple web-application that runs on port 9000. Uploaded this to ECR and started deployment following the documentation.我创建了一个 docker 图像,其中包含一个在端口 9000 上运行的简单 Web 应用程序。将其上传到 ECR 并按照文档开始部署。 I am using Fargate.我正在使用 Fargate。

I defined the task, created a cluster > service with appropriate task version.我定义了任务,创建了一个集群 > 具有适当任务版本的服务。 I have specified this in health check我在健康检查中指定了这个

"CMD-SHELL","curl -f http://localhost:9000/health/check || exit 1"

I have checked the above end-point locally and it works perfectly fine.我已经在本地检查了上述端点,它工作得很好。

I am using ALB and from there I have checked that the target group is configured correctly and I even checked the targets via my bastion host and the health end-point is working fine on the target.我正在使用 ALB,从那里我检查了目标组是否配置正确,我什至通过我的堡垒主机检查了目标,健康端点在目标上运行良好。

curl -f http://<target-ip>:9000/health/check

But when I see the service events, I see the following entry very frequently.但是当我看到服务事件时,我经常看到以下条目。 And I cannot access the web app using ALB url.而且我无法使用 ALB url 访问 web 应用程序。

02434c5e-00f7-4e9a-8716-480791cb164a
2022-12-08 13:15:10 +0530
service hello-service (port 9000) is unhealthy in target-group ecs-pankaj-hello-service-1 due to (reason Request timed out).
1048420a-7e07-42d6-a76b-487989ea280e
2022-12-08 13:12:26 +0530
service hello-service registered 1 targets in target-group ecs-pankaj-hello-service-1
4991efc7-d54c-4984-a2dc-da71a6dc8200
2022-12-08 13:11:08 +0530
service hello-service has started 1 tasks: task b89d8cbf4bad48f2871f5984b4dc2825.
a7002253-53ef-4212-bfcb-f195c4062a42
2022-12-08 13:10:59 +0530
service hello-service deregistered 1 targets in target-group ecs-pankaj-hello-service-1
6c69bda9-792d-434f-9748-878262206e45
2022-12-08 13:10:59 +0530
(service hello-service, taskSet ecs-svc/3722148168959484462) has begun draining connections on 1 tasks.
c1b94455-057a-4b3c-bf5a-df1b3f247474
2022-12-08 13:10:59 +0530
service hello-service deregistered 1 targets in target-group ecs-pankaj-hello-service-1
ffc4387b-1de5-46ee-8a3e-efde12c16e4a
2022-12-08 13:10:49 +0530
service hello-service has stopped 1 running tasks: task ead2367371cf44c2851e1c44bb46ffd0.

Result: I cannot access the web app via ALB url using a browser.结果:我无法使用浏览器通过 ALB url 访问 web 应用程序。

If you receive either of the following errors:如果您收到以下任一错误:

(service AWS-service) (port 8080) is unhealthy in (target-grouparn:uxyztargetgroup/aws-targetgroup/123456789) due to (reason Health checks failed with these codes: [502]) or [request timeout] (service AWS-Service) (port 8080) is unhealthy in target-group tf-20190411170 due to (reason Health checks failed) Try these troubleshooting steps: (服务 AWS 服务)(端口 8080)在 (target-grouparn:uxyztargetgroup/aws-targetgroup/123456789) 中不健康,原因是(原因健康检查失败,这些代码:[502])或 [请求超时](服务 AWS-由于(健康检查失败的原因),服务)(端口 8080)在目标组 tf-20190411170 中不健康 请尝试以下故障排除步骤:

If your container is mapped to port 80, confirm that your container security group allows inbound traffic on port 80 for the load balancer.如果您的容器映射到端口 80,请确认您的容器安全组允许负载均衡器端口 80 上的入站流量。 Confirm that the ping port value for your load balancer health is configured correctly.确认负载均衡器运行状况的 ping 端口值配置正确。 If this port isn't configured correctly, then your load balancer could de-register the container from itself.如果此端口配置不正确,那么您的负载均衡器可能会从自身中注销容器。 Define a minimum health check grace period.定义最小健康检查宽限期。 This instructs the service scheduler to ignore Elastic Load Balancing health checks for a pre-defined time period after a task has been instantiated.这会指示服务调度程序在任务实例化后的预定义时间段内忽略 Elastic Load Balancing 健康检查。 Monitor the CPU and memory metrics of the service.监控服务的 CPU 和 memory 指标。 For example, high CPU can make your application unresponsive and result in a 502 error.例如,高 CPU 会使您的应用程序无响应并导致 502 错误。 Check your application logs for application errors.检查您的应用程序日志以查找应用程序错误。 Check if the ping port and the health check path are configured correctly.检查ping端口和健康检查路径是否配置正确。 Make sure that your backend database is connected successfully.确保您的后端数据库连接成功。 This assumes that your application is running as a set of tasks launched by Amazon Elastic Container Service (Amazon ECS) on Amazon Elastic Compute Cloud (Amazon EC2) instances.这假设您的应用程序作为一组任务运行,这些任务由 Amazon Elastic Container Service (Amazon ECS) 在 Amazon Elastic Compute Cloud (Amazon EC2) 实例上启动。 It also assumes that your application can't communicate with the Amazon Relational Database Service (Amazon RDS) database.它还假设您的应用程序无法与 Amazon Relational Database Service (Amazon RDS) 数据库通信。

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

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