8000 outbound: Cache balancers within profile stack by olix0r · Pull Request #641 · linkerd/linkerd2-proxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

outbound: Cache balancers within profile stack #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 66 commits into from
Aug 31, 2020
Merged

Conversation

olix0r
Copy link
Member
@olix0r olix0r commented Aug 29, 2020

In an upcoming change, we'd like to do service profile discovery within
the TCP-accept stack (and not the HTTP routing stack). But, today,
service profile discovery is tightly coupled to the HTTP middleware
implementations. This change splits the service profile layers (profile
discovery, http request profiles, and traffic splitting) into several
layers, so that the discovery logic is decoupled from the http-specific
request-routing middleware.

This change removes the balancer cache and the balancer-specific buffer
so that balancers are owned by the split layer. The buffer has been
moved outside of the split layer to drive all balancers in a split and
to make the split cloneable (for the retry middleware). All of this is
cached under the profile cache.

Breaking changes:

This likely breaks support for "external" service profiles, where the
proxy resolves service profilse for domains that it cannot resolve via
the resolver. This feature is not enabled by default and is considered
experimental. We'll have to take attention to at least document this in
upcoming releases.

Side-effects:

  • Latency improvements at concurrency image
  • Compile time improved by 20-25% (integration tests in CI ~20m => ~15m);

Copy link
Contributor
@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

this looks great to me so far, nice job on the latency reduction!

Comment on lines +18 to +21
let rng = SmallRng::from_entropy();
layer::mk(move |inner| NewSplit {
inner,
rng: rng.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

should we be doing something like the second example here? i'll admit i'm not too familiar w/ rand's APIs...

Copy link
Member Author

Choose a reason for hiding this comment

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

@hawkw is that the right link? if so, i'm not sure what you're suggesting...

Copy link
Contributor

Choose a reason for hiding this comment

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

whoops, it is not --- i meant to link to here: https://docs.rs/rand/0.7.3/rand/rngs/struct.SmallRng.html#examples

Comment on lines +92 to +95
let mut update = None;
while let Poll::Ready(Some(up)) = self.rx.poll_recv_ref(cx) {
update = Some(up.clone());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

as above, not sure if we need to do this...

Copy link
Member Author
@olix0r olix0r Aug 31, 2020

Choose a reason for hiding this comment

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

If the ready cache isn't ready, then we want to be notified when the profile changes, so we have to drive it to pending. In general, we should always be driving to not ready to be sure we're at the latest state.

olix0r added 4 commits August 31, 2020 17:35
In an upcoming change, we'd like to do service profile discovery within
the TCP-accept stack (and not the HTTP routing stack). But, today,
service profile discovery is tightly coupled to the HTTP middleware
implementations. This change splits the service profile layers (profile
discovery, http request profiles, and traffic splitting) into several
layers, so that the discovery logic is decoupled from the http-specific
request-routing middleware.

This change removes the balancer cache and the balancer-specific buffer
so that balancers are owned by the split layer. The buffer has been
moved outside of the split layer to drive all balancers in a split and
to make the split cloneable (for the retry middleware). All of this is
cached under the profile cache.

Breaking changes:

This likely breaks support for "external" service profiles, where the
proxy resolves service profilse for domains that it cannot resolve via
the resolver. This feature is not enabled by default and is considered
experimental. We'll have to take attention to at least document this in
upcoming releases.

Side-effects:

* Latency improvements at concurrency ![image](https://user-images.githubusercontent.com/240738/91736211-2fd48280-eb62-11ea-8420-30e0242980a5.png)
* Compile time improved by 20-25% (integration tests in CI ~20m => ~15m);
@olix0r olix0r changed the title Ver/profile split outbound: Cache balancers within profile stack Aug 31, 2020
@olix0r olix0r marked this pull request as ready for review August 31, 2020 18:15
@olix0r olix0r requested a review from a team August 31, 2020 18:15
@olix0r olix0r requested a review from hawkw August 31, 2020 18:27
Copy link
Contributor
@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

looks lovely, ship it!

@olix0r olix0r merged commit b89f58c into main Aug 31, 2020
@olix0r olix0r deleted the ver/profile-split branch August 31, 2020 19:24
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Sep 10, 2020
This release includes several major changes to the proxy's behavior:

- Service profile lookups are now necessary and fundamental to outbound
  discovery for HTTP traffic. That is, if a service profile lookup is
  rejected, endpoint discovery will not be performed; and endpoint
  discovery must succeed for all destinations that are permitted by
  service profiles. This simplifies caching and buffering to reduce
  latency (especially under concurrency).
- Service discovery is now performed for all TCP traffic, and
  connections are balanced over endpoints according to connection
  latency.
- This enables mTLS for **all** meshed connections; not just HTTP.
- Outbound TCP metrics are now hydrated with endpoint-specific labels.

---

* outbound: Cache balancers within profile stack (linkerd/linkerd2-proxy#641)
* outbound: Remove unused error type (linkerd/linkerd2-proxy#648)
* Eliminate the ConnectAddr trait (linkerd/linkerd2-proxy#649)
* profiles: Do not rely on tuples as stack targets (linkerd/linkerd2-proxy#650)
* proxy-http: Remove unneeded boilerplate (linkerd/linkerd2-proxy#651)
* outbound: Clarify Http target types (linkerd/linkerd2-proxy#653)
* outbound: TCP discovery and load balancing (linkerd/linkerd2-proxy#652)
* metrics: Add endpoint labels to outbound TCP metrics (linkerd/linkerd2-proxy#654)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Sep 10, 2020
This release includes several major changes to the proxy's behavior:

- Service profile lookups are now necessary and fundamental to outbound
  discovery for HTTP traffic. That is, if a service profile lookup is
  rejected, endpoint discovery will not be performed; and endpoint
  discovery must succeed for all destinations that are permitted by
  service profiles. This simplifies caching and buffering to reduce
  latency (especially under concurrency).
- Service discovery is now performed for all TCP traffic, and
  connections are balanced over endpoints according to connection
  latency.
- This enables mTLS for **all** meshed connections; not just HTTP.
- Outbound TCP metrics are now hydrated with endpoint-specific labels.

---

* outbound: Cache balancers within profile stack (linkerd/linkerd2-proxy#641)
* outbound: Remove unused error type (linkerd/linkerd2-proxy#648)
* Eliminate the ConnectAddr trait (linkerd/linkerd2-proxy#649)
* profiles: Do not rely on tuples as stack targets (linkerd/linkerd2-proxy#650)
* proxy-http: Remove unneeded boilerplate (linkerd/linkerd2-proxy#651)
* outbound: Clarify Http target types (linkerd/linkerd2-proxy#653)
* outbound: TCP discovery and load balancing (linkerd/linkerd2-proxy#652)
* metrics: Add endpoint labels to outbound TCP metrics (linkerd/linkerd2-proxy#654)
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.

2 participants
0