0

I have a use case that force me to use 2 Pair Client/Server, for some illustration : I have 2 processes which each of two are playing Client / Server Role, for this reason I have to create 2 Pair Client/Server. My Question to minimize the overhead of creating 2 Channel to achieve this communication, do we have any possibility to use only one Channel?

Note : Dual streaming wouldn't help, since in my case the two processes play the Server/Client Role.

Thanks for any further help.

fofo
  • 31
  • 3

1 Answers1

0

The overhead of creating a server/client is actually pretty small (too small to play any significant role in most applications.

When we say "creating a new gRPC channel has some overhead and is and expensive operation", it's intended to mean "expensive in comparison to sending a RPC on an established channel". You should not be creating new channels / servers often (e.g. create a new channel for each RPC), but creating a new channel and server once at applications startup is very reasonable thing to do and unless you're doing something that's highly specialized, it's not worth thinking about the overhead of creating a few extra channels.

I don't know details of your use case, but my general response would be "don't try to over-optimize where not necessary" (have you measured the impact actually - you'll probably find it's completely negligible) and I'd simply create the servers/channels you need.

Jan Tattermusch
  • 1,515
  • 9
  • 9