fix(gateway): reuse app address DNS resolver#741
Open
kvinwang wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AppAddressResolverper gateway proxy instead of constructing a DNS resolver per SNI proxy connectionWhy
Creating a new
TokioAsyncResolverfor each proxied connection prevents Hickory's resolver cache from being reused. Keeping the resolver onProxyInnerlets repeated TXT lookups share the resolver cache while preserving DNS TTL semantics for positive records.App-address records can appear shortly after registration, so negative responses are capped to a short TTL for this resolver. That keeps the useful positive cache while avoiding a long-lived negative cache miss for newly-created apps.
The cache is bounded via Hickory's LRU cache size, so many distinct SNI domains evict older entries instead of growing memory without bound.
Verification
cargo check --manifest-path gateway/Cargo.tomlcargo test --manifest-path gateway/Cargo.tomlcargo clippy --manifest-path gateway/Cargo.toml -- -D warnings -D clippy::expect_used -D clippy::unwrap_used --allow unused_variablesbash -n gateway/test-run/test_suite.shshellcheck gateway/test-run/test_suite.shreuse lint