Search code examples
microservicesgrpcrpc

How to implement late-joiner support for gRPC?


I'm considering switching to gRPC. But I can't find any information on the behavior of gRPC on startup of the server. What will happen to an gRPC call if the server is not started jet? And what are the considerations when starting clients and servers at the same time, without using timeouts etc.?


Solution

  • gRPC servers behave like any other server: if the server hasn't started, it won't accept connections.

    gRPC clients connect to servers with exponential backoff. If a service has only a single server and the client starts before that single server, then the client will do exponential backoff trying to connect.

    The connecting behavior has no impact to deadlines. If an RPC is attempted and the last connect attempt failed, then the RPC will be failed immediately unless it was configured as wait-for-ready. Only after a successful connection attempt will RPCs be sent to the server.

    Most of the time there are multiple servers for a service. In these cases the client will ignore the server it can't connect to. Exactly how the client behaves when the server finally starts varies based on the client load balancing policy being used. Pick-first will ignore the new server until the current server it is connected to requests a re-connection. Round-robin continually tries to reconnect and will send traffic to the new server once connecting is successful.