gRPC - How many stubs/clients should I use?

Viewed 760

I am currently developping a massively multi-threaded application that heavily relies on gRPC (only one service)

As I am using a single Channel object shared between threads, the number of stubs/clients I should use is not clear to me.

How many stubs should I instantiate in this case (1 or n)?

Thanks for your help

1 Answers

It doesn't really matter. Channels are the expensive object, whereas stubs/clients are lighter weight. Each stub/client will be an allocation, but otherwise don't really have much overhead.

In Java, you are free to share stubs as they are thread-safe.

Related