You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gRPC probe enhancements to better probe a loadbalanced target #1022
If gRPC probe is probing a load-balanced target with multiple backends, we end up probing just one backend since our gRPC connection is sticky. That's not ideal for the reasons mentioned below. Note that most of the gRPC clients do the same thing -- they establish connection once, and keep on sending all requests on that connection until connection is shutdown for some reason.
Why probing with sticky connection is not ideal:
We end up probing just one backend
An abrupt failure (no connection shutdown) of one of the backends will cause all probes to fail and a gRPC client without a keep-alive (true for our client, and most other clients) will take a really long time (15-16 min[1]) to timeout.
I think we should implement the following changes to the gRPC probe:
Provide an option to not re-use the connection -- in fact consider making it default if possible. Problem with making it default is the existing usage.
Add a way to configure gRPC keep-alive, with ample warning regarding how it's sort of non-deterministic, because of dependence on the server.
[1] - This is based on TCP retries timeout. With a retransmission timeout of 2s and 15 retries (default) with exponential backoff, it will take about 15 minutes for a dead-peer connection to timeout.
To better understand the failure scenario without these changes:
If we don't have gRPC keep-alive (default), and TCP keep-alive (also default), and and server disappears, it might take client 15-16 minutes to timeout and reset the gRPC connection. Only way gRPC connection will timeout is when TCP connection will timeout, and TCP can take really long to timeout on its own. TCP will retransmit packets when it doesn't get acknowledgement from the other side. By default TCP will retry 15 times, with gap between retries increasing exponentially.
If it's a load balanced setup, it will depend on the load balancing method how incoming packets for existing connection are routed.
For full L7 load balancers like nginx and envoy all incoming packets are routed through them. That gives the load balancers better view and control. For example, nginx has a config field called 'grpc_send_timeout' (default: 60s) that will close the connection if request cannot be sent within 60s. Similarly, envoy can automatically drain connections to a bad backend.
For iptables based load balancer, like in k8s ClusterIP, bad backend will be removed from the iptables pretty quickly, but packets for the existing TCP connections will not hit iptables and they will continue to be conntracked to the bad backend.
I think keepalive is not very useful for the scenarios discussed above. For one, keepalive is only used if there is no activity, but more importantly, servers by default don't allow clients to send pings more frequently than 1 every 5min.
Activity
manugarg commentedon Mar 5, 2025
To better understand the failure scenario without these changes:
If we don't have gRPC keep-alive (default), and TCP keep-alive (also default), and and server disappears, it might take client 15-16 minutes to timeout and reset the gRPC connection. Only way gRPC connection will timeout is when TCP connection will timeout, and TCP can take really long to timeout on its own. TCP will retransmit packets when it doesn't get acknowledgement from the other side. By default TCP will retry 15 times, with gap between retries increasing exponentially.
If it's a load balanced setup, it will depend on the load balancing method how incoming packets for existing connection are routed.
iptablesbased load balancer, like in k8s ClusterIP, bad backend will be removed from the iptables pretty quickly, but packets for the existing TCP connections will not hit iptables and they will continue to beconntracked to the bad backend.manugarg commentedon Mar 10, 2025
Option to disabled connection reuse has been implemented. That should solve the issues discussed here. I'll look at implementing keep alive as well.
[probes.grpc] Provide a way to specify default load balancer config. (#…
manugarg commentedon Mar 11, 2025
I think keepalive is not very useful for the scenarios discussed above. For one, keepalive is only used if there is no activity, but more importantly, servers by default don't allow clients to send pings more frequently than 1 every 5min.
manugarg commentedon Mar 11, 2025
I think we can close this issue after changes in #1036 and #1037.