<p>I am new to distributed systems, and came to this problem once needed to deploy a gRPC service to kubernetes (GKE). As far as I know, when a client initiate an rpc, it creates a long lasting http2 connection and further calls are multiplexed on it. I like to send/push notifications or similar messages to the client through this connection. If I deploy to multiple pod, then the connections are spread across them, and not sure what is the best way to locate the instance where the channel is registered to the client. A possible solution could be, as soon as user initiate a connection, keep a reference of clientId and pod ip (or some identification) in a centralized service and other pods lookup the pod and forward the message to it. Is something like is advisable or is there an existing solution for this? I am unfamiliar with this space and any suggestion is highly appreciated.</p>

<p>Edit: (response to @mebius99)</p>

<p>While looking at deploying option, I stumbled upon GKE, and other cloud deployment options were limited because of my use of gRPC/http2. Thanks for mentioning service discovery , and that or service mesh might be an option. With gRPC, client maintains a long lived connection to a single pod. So, I want every pod to be able to query, based on unique clientId (clients can do an initial register rpc call), which pod is it connected, so can make use of this connection and also a way pods to forward the message between them. So, something like when I get a registration call from client, I update the central registry about the client and pod ip, then look it up from any pod and forward package to it so it further forward to client through the existing streaming connection.  You guiding me to the right direction, please let me know above is possible in container environment. </p>

<p>thank you.</p>

bsr
<p>Another idea, You can use Envoy proxy.<br>
If you are using GKE, these posts are helpful.</p>

<ul>
<li><a href="https://cloud.google.com/solutions/exposing-grpc-services-on-gke-using-envoy-proxy" rel="nofollow noreferrer">https://cloud.google.com/solutions/exposing-grpc-services-on-gke-using-envoy-proxy</a></li>
<li><a href="https://github.com/GoogleCloudPlatform/grpc-gke-nlb-tutorial" rel="nofollow noreferrer">https://github.com/GoogleCloudPlatform/grpc-gke-nlb-tutorial</a></li>
</ul>
