why the "loadBalancingPolicy“ must be used when "healthCheckConfig" in grpc


The code file is:
and server

Doubtful code:

var serviceConfig = `{
    "loadBalancingPolicy": "round_robin",
    "healthCheckConfig": {
        "serviceName": ""

Test steps:

1.Run only one server and one client

2.When using "loadBalancingPolicy": "round_robin", the client can detect the "status=NOT_SERVING" of the server

3.When "loadBalancingPolicy": "round_robin" is deleted, or "pick_first" is used, the "status=NOT_SERVING" of the server cannot be detected on the client side


The health check meaningful when has multiple server addresses. If only has one address, there is no need to check health status. So the load balance policy round_robin is work together with health check.

The round_robin will check health status, so it will send request to READY address one after another.

The pick_first policy not support health check, so it will use first success connectted server. So there will only use specify address for any request.

You can read the document of health check and load balance policy in LB Policies Can Disable Health Checking When Needed.

For debug the client and server, you can add environment variable GRPC_GO_LOG_SEVERITY_LEVEL=info and GRPC_GO_LOG_VERBOSITY_LEVEL=99 for more detail of transport and connection event.

Answered By – HelloWood

Answer Checked By – Candace Johnson (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.