Go GRPC, custom balancer, and streaming connections

153 views
Skip to first unread message

zel...@gmail.com

unread,
Jun 30, 2016, 2:30:53 PM6/30/16
to grpc.io
Just curious: when using a custom balancer with Go grpc, I'm assuming a connection will remain open as long as a streaming RPC on it is open, even if the balancer removes it from the list of addresses it returns?

Zellyn

Qi Zhao

unread,
Jun 30, 2016, 2:33:29 PM6/30/16
to Zellyn, grpc.io
correct. But the new rpcs won't take that connection any more.

On Thu, Jun 30, 2016 at 11:30 AM, <zel...@gmail.com> wrote:
Just curious: when using a custom balancer with Go grpc, I'm assuming a connection will remain open as long as a streaming RPC on it is open, even if the balancer removes it from the list of addresses it returns?

Zellyn

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f361dfeb-a639-4858-8c8f-984f43833b2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
-Qi

zel...@gmail.com

unread,
Jun 30, 2016, 3:02:15 PM6/30/16
to grpc.io, zel...@gmail.com
Thanks. One followup question.

If a balancer has requested that a connection be closed (by removing it from the slices sent over the Notify() channel), but it hasn't yet closed (because something is still using it), so the "down" func has not yet been called yet, and then the balancer adds it back to the list of desired connections (by adding it to the slice again), will Up() be called again for that connection?

Zellyn


On Thursday, June 30, 2016 at 2:33:29 PM UTC-4, Qi Zhao wrote:
correct. But the new rpcs won't take that connection any more.
On Thu, Jun 30, 2016 at 11:30 AM, <zel...@gmail.com> wrote:
Just curious: when using a custom balancer with Go grpc, I'm assuming a connection will remain open as long as a streaming RPC on it is open, even if the balancer removes it from the list of addresses it returns?

Zellyn

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f361dfeb-a639-4858-8c8f-984f43833b2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
-Qi

Qi Zhao

unread,
Jun 30, 2016, 5:16:44 PM6/30/16
to Zellyn, grpc.io
On Thu, Jun 30, 2016 at 12:02 PM, <zel...@gmail.com> wrote:
Thanks. One followup question.

If a balancer has requested that a connection be closed (by removing it from the slices sent over the Notify() channel), but it hasn't yet closed (because something is still using it), so the "down" func has not yet been called yet, and then the balancer adds it back to the list of desired connections (by adding it to the slice again), will Up() be called again for that connection?
down will be called once the receiver of Notify() channel reads it (https://github.com/grpc/grpc-go/blob/master/clientconn.go#L359) regardless whether there are pending rpcs on it or not (note that down() has to be called to prevent the later rpcs from choosing that connection). 

Even if the balancer gets the address back before the receiver of Notify() reads the updates, there is no issue because the reads from the Notify() channel are serialized -- the connection will be tore down first then re-established.

Zellyn

On Thursday, June 30, 2016 at 2:33:29 PM UTC-4, Qi Zhao wrote:
correct. But the new rpcs won't take that connection any more.

On Thu, Jun 30, 2016 at 11:30 AM, <zel...@gmail.com> wrote:
Just curious: when using a custom balancer with Go grpc, I'm assuming a connection will remain open as long as a streaming RPC on it is open, even if the balancer removes it from the list of addresses it returns?

Zellyn

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/f361dfeb-a639-4858-8c8f-984f43833b2a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks,
-Qi

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.

To post to this group, send email to grp...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks,
-Qi

Zellyn Hunter

unread,
Jul 28, 2016, 5:04:21 PM7/28/16
to Qi Zhao, grpc.io
Even if the balancer gets the address back before the receiver of Notify() reads the updates, there is no issue because the reads from the Notify() channel are serialized -- the connection will be tore down first then re-established.

I'm assuming that a connection with ongoing streaming RPCs won't actually be torn down until the RPCs complete, right? Or am I wrong, and they're forcibly closed?

If they're left open, it would be nice to -- if we ever decide to re-connect to a previously-connected address -- to keep using the existing connection, rather than opening a new one every time. Is that possible? For instance, we sometimes rebalance our connections every ten minutes, just to make sure things are, on average, balanced. In a world where there are lots of streaming RPCs keeping connections open, this could result in a new connection every time we rebalance, even if we end up using the same address at times.

Zellyn
Reply all
Reply to author
Forward
0 new messages