Skip to content

gRPC probe enhancements to better probe a loadbalanced target #1022

Closed

Description

@manugarg

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:

  1. 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.
  2. 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.

Activity

  1. added
    enhancement
    on Feb 27, 2025
  2. manugarg commented on Mar 5, 2025

    @manugarg
    ContributorAuthor

    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.
  3. manugarg commented on Mar 10, 2025

    @manugarg
    ContributorAuthor

    Option to disabled connection reuse has been implemented. That should solve the issues discussed here. I'll look at implementing keep alive as well.

  4. self-assigned this
    on Mar 10, 2025
  5. manugarg commented on Mar 11, 2025

    @manugarg
    ContributorAuthor

    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.

  6. manugarg commented on Mar 11, 2025

    @manugarg
    ContributorAuthor

    I think we can close this issue after changes in #1036 and #1037.

  7. added this to the v0.14.0 milestone on Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions