-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
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
@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&) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: affect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
RDS does not require cache invalidation in and of itself, as the caching is per request, not global. |
#389 did not actually cache them between filters which was the point of the previous change.
#389 did not actually cache them between filters which was the point of the previous change.
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]>
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]>
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