问题
When we create a managedChannelBuilder and use this to call a grpc-java service call, how many clients can we serve with this? Doesn't this channel be shutdown after individual service call? Say I have a REST interface which accepts REST calls from a browser and from within these REST Service methods, I am making grpc client calls to an independent grpc server. Also I can expect client connections in the range of [4000-5000] concurrently. How well can I make use of this managedChannelBuilder. Do I need just one? Or do I need to pool multiple channelbuilders?
回答1:
Generally, I'd suggest using a single ManagedChannel
per endpoint when your code can be easily structured to share it. ManagedChannel
multiplexes RPCs and is thread-safe, so it can handle multiple RPCs concurrently.
In rarer cases of high very high throughput, it may make sense to use more than one ManagedChannel
. Eventually ManagedChannel
(or, maybe Channel
) should have support for doing this natively.
来源:https://stackoverflow.com/questions/43119082/what-is-the-maximum-number-of-clients-that-a-grpc-java-managedchannelbuilder-can