Add cache for CNAME mappings resolved during lookup of DNS entries.#8314
Merged
normanmaurer merged 2 commits into4.1from Sep 27, 2018
Merged
Add cache for CNAME mappings resolved during lookup of DNS entries.#8314normanmaurer merged 2 commits into4.1from
normanmaurer merged 2 commits into4.1from
Conversation
Member
Author
|
Also /cc @slandelle @vietj |
a91daad to
ba686fc
Compare
Motivation: If the CNAMEd hostname is backed by load balancing component, typically the final A or AAAA DNS records have small TTL. However, the CNAME record itself is setup with longer TTL. For example: * x.netty.io could be CNAMEd to y.netty.io with TTL of 5 min * A / AAAA records for y.netty.io has a TTL of 0.5 min In current Netty implementation, original hostname is saved in resolved cached with the TTL of final A / AAAA records. When that cache entry expires, Netty recursive resolver sends at least two queries — 1st one to be resolved as CNAME record and the 2nd one to resolve the hostname in CNAME record. If CNAME record was cached, only the 2nd query would be needed most of the time. 1st query would be needed less frequently. Modifications: Add a new CnameCache that will be used to cache CNAMEs and so may reduce queries. Result: Less queries needed when CNAME is used.
ba686fc to
daa7b42
Compare
trustin
approved these changes
Sep 27, 2018
| * A cache for {@code CNAME}s. | ||
| */ | ||
| @UnstableApi | ||
| public interface CnameCache { |
Member
There was a problem hiding this comment.
DnsCnameCache? Not strong on this though.
| } | ||
|
|
||
| /** | ||
| * Returns the cname cache. |
Member
There was a problem hiding this comment.
- cname cache ->
{@link CnameCache}?
Member
Author
|
@trustin addressed. |
1c54bd9 to
973ddff
Compare
normanmaurer
added a commit
that referenced
this pull request
May 8, 2020
Motivation: In netty there is a seperate CNAME cache that is used to cache CNAMEs that are resolved during resolving an A / AAAA record. While this sounded like a great idea when I first implemented this in netty it turned out this is problematic and may produce errors while resolving hostnames later on. The problem with the CNAME cache is that we may end up with entries in the CNAME cache wile the original cached resolution was already removed from the cache (due TTL). In this case we may find an entry in teh CNAME cache that we will then try to resolve via the specified nameserver. This resolution may fail as the nameserver may not return an entry for the previous cached CNAME. This usually happens when we receive the full "resolution chain" during query for an A / AAAA record. This problem was introduced by #8314 Modifications: - Use the NoopDnsCnameCache by default - Deprecate methods that allow to set a custom DnsCnameCache - Deprecate DnsCnameCache and all the implementations - Add unit test Result: Fixes resolution problem caused by cached cname records
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.
Motivation:
If the CNAMEd hostname is backed by load balancing component, typically the final A or AAAA DNS records have small TTL. However, the CNAME record itself is setup with longer TTL.
For example:
In current Netty implementation, original hostname is saved in resolved cached with the TTL of final A / AAAA records. When that cache entry expires, Netty recursive resolver sends at least two queries — 1st one to be resolved as CNAME record and the 2nd one to resolve the hostname in CNAME record.
If CNAME record was cached, only the 2nd query would be needed most of the time. 1st query would be needed less frequently.
Modifications:
Add a new CnameCache that will be used to cache CNAMEs and so may reduce queries.
Result:
Less queries needed when CNAME is used.