英文:
gRPC Health Checks on AWS ALB
问题
无论我提供哪种健康检查路径,即使它是完全随意的文本,只要匹配器代码设置为0,健康检查才能通过。
我有一个服务,它只是使用AWS示例提供的默认路径 - /AWS.ALB/healthcheck
。它通过了,匹配器代码为0。
另一个服务实现了一个特定的健康检查路径,成功时返回1,但除非将匹配器代码设置为0,否则检查仍然失败。值得注意的是,这个服务实现了服务器反射。
我是否漏掉了什么关键部分?我大致按照官方示例中的设置进行了操作。
英文:
No matter which health check path I provide, even if it's completely arbitrary text, the health check will only pass as long if the matcher code is set to 0.
I have one service that's just using the default path given by the AWS example - /AWS.ALB/healthcheck
. It's passing with a 0.
Another service has implemented a specific health check path that returns 1 on success, but the check continues to fail unless the matcher code is set to 0. It's worth noting that this service has implemented server reflection.
Am I missing a piece here? I more or less followed the setup in the official example.
答案1
得分: 1
根据官方GRPC响应代码文档,响应代码为0表示
不是错误;在成功时返回。
这将是已通过的健康检查的正确返回值。
我不确定您提供的博客文章是如何得出响应代码“12”(未实现)表示健康检查已通过的想法的,但这绝对不应该是这种情况。
您确实应该努力使您的GRPC服务返回成功的代码0,因为这是指示健康服务的标准机制。
我已嵌入了从链接网站中获取的图像,以防将来的查看者无法访问。
英文:
Per the official GRPC documentation on response codes, a response code of 0 indicates
> Not an error; returned on success.
This would be the correct return value for a health check that has passed.
I'm not sure where the blog post you linked to got the idea that a response code of "12" (UNIMPLEMENTED) is indicative of a health check passing, but this certainly shouldn't be the case.
You should definitely be aiming to have your GRPC services return a code of 0 for success as this is the standard mechanism for indicating a healthy service.
I have embedded an image taken from the linked website in the event it is not available for future viewers.
答案2
得分: 1
AWS目标组的协议版本设置为gRPC将默认为以下内容:
- HealthCheckPath:
/AWS.ALB/healthcheck
- 匹配器(预期状态码):
12
(未实现)
这直接来自Amazon的文档:https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html。
您可以更改这些值,但是您的gRPC服务不会具有完全匹配默认路径 /AWS.ALB/healthcheck
(包 = AWS
,服务 = ALB
,一元RPC = healthcheck
)的精确RPC,因此Amazon的默认预期状态码12(未实现)是合理的。
尽管如此,如果您选择将自己的逼真健康检查作为服务上的RPC实现,建议使用更符合习惯的响应代码来指示成功(0 OK)。例如,/com.mypackage/ServiceA.healthcheck
应返回0 OK,并将其目标组的健康检查匹配器设置为0 OK。
英文:
AWS Target Groups with the protocol version set to gRPC will default to the following:
- HealthCheckPath:
/AWS.ALB/healthcheck
- Matcher (expected status code):
12
(Unimplemented)
This is directly from Amazon's documentation: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html.
You can change these values, but your gRPC services are not going to have the precise RPC that exactly matches the default /AWS.ALB/healthcheck
(package = AWS
, service = ALB
, unary rpc = healthcheck
) and therefore Amazon's default expected status code of 12 (Unimplemented) makes sense.
That said, if you choose to implement your own realistic health check as an RPC on your service, it is recommended to use a more idiomatic response code to indicate success (0 OK). For example, a /com.mypackage/ServiceA.healthcheck
should return a 0 OK and have its target group's health check matcher set to 0 OK as well.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论