Skip to content

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

Merged
mattklein123 merged 4 commits intomasterfrom
cache_route
Jan 30, 2017
Merged

perf: cache HTTP route when looked up by filters#389
mattklein123 merged 4 commits intomasterfrom
cache_route

Conversation

@mattklein123
Copy link
Copy Markdown
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
Copy Markdown
Member Author

@lyft/network-team @rshriram

}

bool FaultFilter::matchesTargetCluster(const HeaderMap& headers) {
bool FaultFilter::matchesTargetCluster(const HeaderMap&) {
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.

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 <achiu@lyft.com>

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 <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Signed-off-by: Alan Chiu <achiu@lyft.com>

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 <jp@jpsim.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
**Commit Message**

At the first iteration of the "getting started guide", I added `--fail`
in all commands as we had an automated testing of the site documentation
and it allowed us to detect if the curl command not is working. However,
now we don't have any tests like that + `--fail` prevents users from
seeing the actual error response from the upstream which makes it
difficult to troubleshoot since it suppresses the response body due to
the early cancel of requests.

**Related Issues/PRs (if applicable)**

The root cause of #379 #375

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
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