简体   繁体   English

如何添加运行状况检查以检查我在 aws autoscale 中的实例是否与另一个独立实例成功建立了连接

[英]How can I add a health check to check if my instances in aws autoscale established a successful connection with another independent instance

Currently I have multiple instances running under AWS autoscale group which polls messages from AWS SQS.目前,我有多个实例在 AWS 自动缩放组下运行,该组从 AWS SQS 轮询消息。 My instances needs to establish connection with another instance before it start processing the incoming messages.我的实例需要在开始处理传入消息之前与另一个实例建立连接。

Sometimes it happens that one of my instances couldn't establish the connection, and I want to add a health check here to monitor the connection status and terminate the instance based on that.有时会发生我的一个实例无法建立连接的情况,我想在这里添加一个健康检查来监控连接状态并基于此终止实例。 I don't think the default EC2 health check takes care of this scenario.我认为默认的 EC2 运行状况检查不会处理这种情况。

Is there any way I can add a health check to handle the above mentioned scenario.有什么办法可以添加健康检查来处理上述情况。

You really need some sort of custom health check for this as any of the built in metrics (like CPU usage, network in/out) aren't going to work here.您确实需要为此进行某种自定义运行状况检查,因为任何内置指标(如 CPU 使用率、网络输入/输出)在这里都不起作用。

One idea would be to have these instances bootstrapped with a cron job that runs every few minutes and checks if the the connection is up and running.一种想法是让这些实例使用每隔几分钟运行一次的 cron 作业进行引导,并检查连接是否已启动并正在运行。 If not, the instance could set itself as unhealthy using the CLI or SDK.否则,实例可能会使用 CLI 或 SDK 将自身设置为不健康。

Here is an example piece of bash code that gets the instance ID of the instance the code is running on and then marks itself as unhealthy.这是一段 bash 代码示例,它获取运行代码的实例的实例 ID,然后将自身标记为不健康。 This would trigger the ASG to replace it.这将触发 ASG 更换它。

EC2_INSTANCE_ID="`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`"
aws autoscaling set-instance-health --instance-id $EC2_INSTANCE_ID --health-status Unhealthy

Resources:资源:

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

相关问题 如何检查是否与 AWS 实例建立了 SSH 连接 - How to check if SSH connection was established with AWS instance 如何向Sagemaker端点添加健康检查? - How can I add a health check to a Sagemaker Endpoint? 如何在 AWS CloudFormation 模板中的 Elastic Beanstalk 实例上设置运行状况检查 URL? - How do I set the health-check URL on an Elastic Beanstalk instance in a AWS CloudFormation template? 当实例无法通过运行状况检查时,AWS ECS服务将移至另一个集群 - AWS ECS services are moving to another cluster when instances fail health check 如何指示AWS ELB考虑将403代码恢复成功的运行状况检查? - How to instruct an AWS ELB to consider a health check that returns a 403 code as successful? AWS 的运行状况检查端点 - Health check endpoint for AWS AWS Cognito 健康检查 - AWS Cognito Health Check 为什么我的 AWS Lightsail 实例在附加到负载均衡器时出现“运行状况检查:失败”? - Why my AWS Lightsail instance got “Health Check: Failed” when attach to a load balancer? Route 53 Amazon Aws-在我的ec2实例中检查服务(Solr)运行状况 - Route 53 Amazon Aws - Check service (Solr) health in my ec2 instance AWS:如何创建 ELB 运行状况检查端点? - AWS: How to create an ELB health check endpoint?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM