Skip to content
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

perf: cache HTTP route when looked up by filters #389

Merged
merged 4 commits into from
Jan 30, 2017
Merged

Conversation

mattklein123
Copy link
Member

If multiple filters consult the route table, the same route can be looked
up many times. With large route tables, this can become quite expensive.
This change adds caching for the route lookup and changes the interfaces
so that headers are no longer passed when getting a stable route. In
the future we may need to add route cache clearing, but for now this is
fine.

fixes #372

If multiple filters consult the route table, the same route can be looked
up many times. With large route tables, this can become quite expensive.
This change adds caching for the route lookup and changes the interfaces
so that headers are no longer passed when getting a stable route. In
the future we may need to add route cache clearing, but for now this is
fine.

fixes #372
@mattklein123
Copy link
Member Author

@lyft/network-team @rshriram

@@ -149,11 +149,11 @@ void FaultFilter::abortWithHTTPStatus() {
callbacks_->requestInfo().setResponseFlag(Http::AccessLog::ResponseFlag::FaultInjected);
}

bool FaultFilter::matchesTargetCluster(const HeaderMap& headers) {
bool FaultFilter::matchesTargetCluster(const HeaderMap&) {
Copy link
Member

Choose a reason for hiding this comment

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

You could get rid of the headers arg completely. It's used only to obtain the target cluster from connection manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

will fix

* Returns the route for the current request. The assumption is that the implementation can do
* caching where applicable to avoid multiple lookups.
*
* NOTE: This breaks down a bit if the caller knows it has modified something that would effect
Copy link
Member

Choose a reason for hiding this comment

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

nit: affect

* NOTE: This breaks down a bit if the caller knows it has modified something that would effect
* routing (such as the request headers). In practice, we don't do this anywhere currently,
* but in the future we might need to provide the ability to clear the cache if a filter
* knows that it has modified the headers in a way that would effect routing. In the future
Copy link
Member

Choose a reason for hiding this comment

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

nit: affect

Copy link
Member

@rshriram rshriram left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@RomanDzhabarov RomanDzhabarov left a comment

Choose a reason for hiding this comment

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

LGTM, also we'd need to invalidate that cache when we have RDS in place.

@mattklein123
Copy link
Member Author

RDS does not require cache invalidation in and of itself, as the caching is per request, not global.

@mattklein123 mattklein123 merged commit 3202ab8 into master Jan 30, 2017
@mattklein123 mattklein123 deleted the cache_route branch January 30, 2017 21:07
mattklein123 added a commit that referenced this pull request Feb 9, 2017
#389 did not actually cache them
between filters which was the point of the previous change.
mattklein123 added a commit that referenced this pull request Feb 9, 2017
#389 did not actually cache them
between filters which was the point of the previous change.
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
rshriram pushed a commit to rshriram/envoy that referenced this pull request Oct 30, 2018
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Signed-off-by: Alan Chiu <[email protected]>

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: docs: add some intellij instructions
Risk Level: low
Testing: local
Docs Changes: tools
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <[email protected]>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Signed-off-by: Alan Chiu <[email protected]>

For an explanation of how to fill out the fields, please see the relevant section
in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md)

Description: docs: add some intellij instructions
Risk Level: low
Testing: local
Docs Changes: tools
Release Notes: n/a
[Optional Fixes #Issue]
[Optional Deprecated:]

Signed-off-by: JP Simard <[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.

perf: eliminate repeated route lookups in http filters
4 participants