[Java] Reporting server's overall health status with HealthStatusManager

722 views
Skip to first unread message

Kun Zhang

unread,
Nov 13, 2018, 7:14:43 PM11/13/18
to grpc.io
This is to answer a question originally asked on https://github.com/grpc/grpc-java/issues/4696 by chabmed:

Hi, maybe it's not a bug I just need some clarification about the health check,
https://github.com/grpc/grpc/blob/master/doc/health-checking.md, it's mentioned that the empty string should be used as the key for server's overall health status. But inside the code i'm not seeing anything special using empty string, and when querying the helthStatus check with empty string, i receive UNKNOWN_SERVICE. I want to use this rpc for the readinessProbe in kubernetes. i'm seeing in the master branch (1.17.0) the class HealthStatusManager

/**
 * The special "service name" that represent all services on a GRPC server. It is an empty
 * string.
 */
public static final String SERVICE_NAME_ALL_SERVICES = "";

But it's not used. Am I missing something here, I know it's still an experimental API, should I implement my own non grpc health check in this case?


To use health-checking service, the application should create a HealthStatusManager and register getHealthService() to the server. The application can then set the serving status on the HealthStatusManager whenever desired. Because the serving status is always associated with a service, designated by a string, we define the empty string as the special service name to indicate the "whole server". This is a convention meant to communicate the health status of a whole server between the client and the server. The SERVICE_NAME_ALL_SERVICES constant is for the application server to use to set it, and for the application client to query it through RPC.

chabchoub....@gmail.com

unread,
Nov 15, 2018, 11:38:27 AM11/15/18
to grpc.io
Hi thanks for answering my question. But what do you mean the "whole server", checking all the grpc services registered? or it's for the application to define what they want to check before returning by a healthy status?

--Thanks

Eric Anderson

unread,
Nov 16, 2018, 1:57:14 PM11/16/18
to chabchoub....@gmail.com, grp...@googlegroups.com
Ideally every caller would know what service they are interested in and specify that service name. But it might be hard/annoying to configure the client to query a specific service and most pre-existing health checking systems aren't service-specific, but server-wide. So basically that means that many (most?) people will just use empty string and move on with life. For example, in k8s readiness is job-wide; if your job is providing multiple services you can tell k8s you're ready for service A but not ready for service B.

But occasionally you have issues where you have a single server with two sets of semi-independent services. (Rather, the services may be related, but they may fail independently.) In those cases it is nice for clients to be able to specify in which service they are interested.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/fd8c621f-814c-4237-8b40-7be42c455030%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages