0

In my chat app (Nest.js + gRPC microservices) I need to send requests (to create messages) as fast as possible and I worry that reopening the connection (if it is the case) can take too much time and resources.

I tried searching the docs but didn't find any clear answer. Will the connection reopen each time I make a unidirectional call?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • 2
    Does this answer your question? [does @grpc/grpc-js reuse the http2 connection or does it create new connection for each call/request](https://stackoverflow.com/questions/76730026/does-grpc-grpc-js-reuse-the-http2-connection-or-does-it-create-new-connection-f) – murgatroid99 Jul 20 '23 at 16:31

1 Answers1

1

HTTP/2 supports multiplexing, which allows multiple requests and responses to be sent and received over a single connection concurrently. This means that multiple gRPC calls can be performed over the same HTTP/2 connection simultaneously, even if they are initiated almost simultaneously.

Though, it's essential to note that the behavior may vary based on the specific gRPC library implementation and configurations. Some libraries might have connection pooling mechanisms or other strategies to optimize connection usage. Additionally, the server may limit the number of concurrent streams on a single connection, which could result in opening additional connections if the limit is reached.