Looking at gRPC Java doc - ManagedChannelBuilder, there're two options to manage the connections. It seems idleTimeout() is the default/preferred configuration. But when I tried to search for a comparison, most of the posts are talking about keepAlive option.
I'm curious about what's the common practise and what are the pros and cons of these two options?
Set the duration without ongoing RPCs before going to idle mode. In idle mode the channel shuts down all connections, the NameResolver and the LoadBalancer. A new RPC would take the channel out of idle mode. A channel starts in idle mode. Defaults to 30 minutes.
This is an advisory option. Do not rely on any specific behavior related to this option.
Sets whether keepalive will be performed when there are no outstanding RPC on a connection. Defaults to false.
Clients must receive permission from the service owner before enabling this option. Keepalives on unused connections can easilly accidentally consume a considerable amount of bandwidth and CPU. idleTimeout() should generally be used instead of this option.