Skip to content

DFP: Track connections in the DFP LoadBalancer - #17874

Merged
htuch merged 39 commits into
envoyproxy:mainfrom
RyanTheOptimist:DFPwithCallbacks
Oct 21, 2021
Merged

htuch merged 39 commits into
envoyproxy:mainfrom
RyanTheOptimist:DFPwithCallbacks

Conversation

@RyanTheOptimist

Copy link
Copy Markdown
Contributor

Widen the Upstream::LoadBalancer interface to add methods which allow
a load balancer to optionally observe connection lifetime events and to
select a specific connection based on those events.

Implement this behavior in the DFP LoadBalancer to reuse HTTP/2 and HTTP/3
connections when the hash key, IP address, and certificate all match, conditional
on a new allow_coalesced_connections field in the DFP config.

Signed-off-by: Ryan Hamilton [email protected]

Risk Level: Low
Testing: Unit
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

a load balancer to optionally observe connection lifetime events and to
select a specific connection based on those events.

Implement this behavior in the DFP LoadBalancer to reuse HTTP/2 and HTTP/3
onnections when the hash key, IP address, and certificate all match.

Signed-off-by: Ryan Hamilton <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
envoyproxy/api-shepherds assignee is @htuch
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #17874 was opened by RyanTheOptimist.

see: more, trace.

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @RenjieTang

@RenjieTang RenjieTang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Minor question.
Also I can't access the design doc you provided.

@RyanTheOptimist RyanTheOptimist left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the doc permissions. You should have access now.

RenjieTang
RenjieTang previously approved these changes Aug 26, 2021

@snowp snowp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems really cool, thanks for working on it! Some comments to get this started

Comment thread envoy/http/conn_pool.h Resolved
Comment thread envoy/upstream/load_balancer.h Resolved
Comment thread envoy/upstream/load_balancer.h Resolved
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>

@RyanTheOptimist RyanTheOptimist left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thoughtful comments!

Comment thread envoy/http/conn_pool.h Resolved
Comment thread envoy/upstream/load_balancer.h Resolved
Comment thread envoy/upstream/load_balancer.h Resolved
}

absl::optional<Upstream::SelectedPoolAndConnection>
Cluster::LoadBalancer::selectPool(Upstream::LoadBalancerContext* context,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is hard! Thanks for thinking through this! I like the idea of adding "Existing" to the name (since that would help clarify the semantics). How about selectExistingConnection? (Since it selects a connection within a pool). I've not changed the name in the PR, but once we agree I will.

Comment on lines +39 to +42
// the TLS certificate is also valid for the new hostname. For example, if a connection
// has previously been established to foo.example.com at IP 1.2.3.4 with a certificate
// that is valid for *.example.com, then this connection could be used for requests to
// bar.example.com if that also resolved to 1.2.3.4.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is legit from RFC point of view but it's not how envoy likes.

The idea is bar.example.com is valid for ".example.com" but it might not the upstream envoy wants.
Envoy may don't like "bar.example.com" even if the cert accept "
.example.com"

See #6767 (comment)

  1. Can you add the the risk that when not to use allow_coalesced_connections? Otherwise, I would no brain turn on it when read your description.

  2. It seems the implementation applies to forward proxy cluster but it's not clear in the doc here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Hm, this sounds like a good idea. I'm not quite sure how to phrase this though. I've taken a stab. Please take a look!
  2. I'm not sure I understand. This is the doc for the forward cluster so I would have expected that it would be clear that the config described here is only for the cluster. Can you suggest some text to add to make this more clear?

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@snowp snowp self-assigned this Aug 31, 2021

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API looks good, but would like to clarify doc nit and needs version history entry.
/wait

Signed-off-by: Ryan Hamilton <[email protected]>
@snowp

snowp commented Oct 4, 2021

Copy link
Copy Markdown
Contributor

Seems like coverage is still failing, can you take a look?

/wait

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only

Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #17874 (comment) was created by @RyanTheOptimist.

see: more, trace.

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

@alyssawilk this has FINALLY cleared CI and is hopefully ready for your review.

@alyssawilk

Copy link
Copy Markdown
Contributor

I don't think I'm assigned to this one. If you want me to be, you can now assign me using the UI and not /assign otherwise @snowp can do a pass :-)

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

I don't think I'm assigned to this one. If you want me to be, you can now assign me using the UI and not /assign otherwise @snowp can do a pass :-)

Oh. My unfamiliarity with GitHub strikes again. You're listed in the "Reviewers" section at the top but that's not the same as being Assigned. Gotcha! In that case, I'm happy to defer to @snowp!

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

I don't think I'm assigned to this one. If you want me to be, you can now assign me using the UI and not /assign otherwise @snowp can do a pass :-)

Oh. My unfamiliarity with GitHub strikes again. You're listed in the "Reviewers" section at the top but that's not the same as being Assigned. Gotcha! In that case, I'm happy to defer to @snowp!

@snowp friendly ping

@snowp snowp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

API looks good, but would like to clarify doc nit and needs version history entry. /wait

I think this is all resolved now. @htuch can you take another look from an API perspective?

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api

@htuch
htuch merged commit b404746 into envoyproxy:main Oct 21, 2021
agrawroh pushed a commit that referenced this pull request Apr 13, 2026
…43702)

## Commit Message
http: wire ConnectionLifetimeCallbacks into pool connection events

## Description
Wires up the `ConnectionLifetimeCallbacks` interface that is there but
is not connected to actual connection events from what I see at least.
The cluster manager now passes the LB's callbacks into each HTTP pool at
creation time, and `MultiplexedActiveClientBase` fires them on
Connected, Close, and GOAWAY events.

Primary motivation: allows the reverse tunnel cluster's LB to detect
GOAWAY and report it to the tunnel reporter ([raw
example](aakugan@31094c9)).
Also applicable to DFP clusters for connection coalescing awareness from
what I [see](#17874).

## Risk Level
Should be low. Additive-only changes to production code. Callbacks are
no-ops unless explicitly set by the LB. No behavior change for existing
clusters.

## Testing
- HTTP/2 conn pool unit tests (7 tests): no-op without callbacks,
Connected/RemoteClose/LocalClose with arg verification, GOAWAY with
active streams, idle GOAWAY, callback replacement.
- HTTP/3 conn pool unit test: Connected + idle GOAWAY through
`MultiplexedActiveClientBase`.
- Cluster manager unit tests: verifies `setLifetimeCallbacks` is called
on pool creation.

## Docs Changes
N/A

## Release Notes
N/A

---------

Signed-off-by: aakugan <[email protected]>
Copilot AI pushed a commit to mmorel-35/envoy that referenced this pull request Apr 13, 2026
…nvoyproxy#43702)

## Commit Message
http: wire ConnectionLifetimeCallbacks into pool connection events

## Description
Wires up the `ConnectionLifetimeCallbacks` interface that is there but
is not connected to actual connection events from what I see at least.
The cluster manager now passes the LB's callbacks into each HTTP pool at
creation time, and `MultiplexedActiveClientBase` fires them on
Connected, Close, and GOAWAY events.

Primary motivation: allows the reverse tunnel cluster's LB to detect
GOAWAY and report it to the tunnel reporter ([raw
example](aakugan@31094c9)).
Also applicable to DFP clusters for connection coalescing awareness from
what I [see](envoyproxy#17874).

## Risk Level
Should be low. Additive-only changes to production code. Callbacks are
no-ops unless explicitly set by the LB. No behavior change for existing
clusters.

## Testing
- HTTP/2 conn pool unit tests (7 tests): no-op without callbacks,
Connected/RemoteClose/LocalClose with arg verification, GOAWAY with
active streams, idle GOAWAY, callback replacement.
- HTTP/3 conn pool unit test: Connected + idle GOAWAY through
`MultiplexedActiveClientBase`.
- Cluster manager unit tests: verifies `setLifetimeCallbacks` is called
on pool creation.

## Docs Changes
N/A

## Release Notes
N/A

---------

Signed-off-by: aakugan <[email protected]>
Co-authored-by: mmorel-35 <[email protected]>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
…nvoyproxy#43702)

## Commit Message
http: wire ConnectionLifetimeCallbacks into pool connection events

## Description
Wires up the `ConnectionLifetimeCallbacks` interface that is there but
is not connected to actual connection events from what I see at least.
The cluster manager now passes the LB's callbacks into each HTTP pool at
creation time, and `MultiplexedActiveClientBase` fires them on
Connected, Close, and GOAWAY events.

Primary motivation: allows the reverse tunnel cluster's LB to detect
GOAWAY and report it to the tunnel reporter ([raw
example](aakugan@31094c9)).
Also applicable to DFP clusters for connection coalescing awareness from
what I [see](envoyproxy#17874).

## Risk Level
Should be low. Additive-only changes to production code. Callbacks are
no-ops unless explicitly set by the LB. No behavior change for existing
clusters.

## Testing
- HTTP/2 conn pool unit tests (7 tests): no-op without callbacks,
Connected/RemoteClose/LocalClose with arg verification, GOAWAY with
active streams, idle GOAWAY, callback replacement.
- HTTP/3 conn pool unit test: Connected + idle GOAWAY through
`MultiplexedActiveClientBase`.
- Cluster manager unit tests: verifies `setLifetimeCallbacks` is called
on pool creation.

## Docs Changes
N/A

## Release Notes
N/A

---------

Signed-off-by: aakugan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants