skip to Main Content

I have a grpc project and I want to send request between multi server with grpc. so, I want to cache grpcChannels to use every times. How can i save grpcChannels into redis with one key?

Cache grpc channel into Redis Database

2

Answers


  1. Chosen as BEST ANSWER

    Unfortunately, it is not possible to store and load a grpc channel from Redis. The main resource of a grpc channel is opened connection(s) to the other side (client/server) which are like file descriptors for your app and that is why it can't be load from redis. But this is not a problem: just reuse a channel as much as possible in your app, i.e., do not close a channel after every RPC call (more on this here https://learn.microsoft.com/en-us/aspnet/core/grpc/performance?view=aspnetcore-6.0#reuse-grpc-channels). But it is ok for the app process to create a channel on startup


  2. Refer to this doc from Microsoft about the best practice for using gRPC. A quote from the doc:

    gRPC clients are created with channels. gRPC clients are lightweight objects and don’t need to be cached or reused.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search