mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #2214] DNS Resolver rotate feature #923
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#923
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TSDevHub on GitHub (May 17, 2024).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2214
Is your feature request related to a problem? Please describe.
Hello, I want to DNS cache a query which yields multiple A records and rotate through the A records.
I know you guys have https://docs.rs/hickory-resolver/0.24.1/hickory_resolver/config/struct.ResolverOpts.html#structfield.rotate feature, but upon inspecting your resolver source code, doesn't seem hickory resolver use it to rotate between cached A records for a given query, which would be useful for ip load balancing for services that use round-robin DNS. I also verified that with this rotate flag on, hickory resolver do not rotate between cached records, so if I am DNS caching, it just uses the same record even though in the IRU cache, hickory stores all the records for the query. This could be bad for overloading that particular ip.
Having the rotate feature work would make hickory resolver more adoptable for users trying to call service domain endpoint which use round-robin DNS for load balancing. Also might prevent users who enabled hickory resolver caching from unexpectedly bringing down their destination service hosts, due to surge in load in one ip due to caching.
Describe the solution you'd like
Allow hickory resolver to honor the rotate option, and round-robin rotate cached DNS query records.
Suppose we made DNS query for domain www.myservice.com and it came up with these A records
rotate would alternate fetching A records from DNS cache like so
1.2.3.4->5.6.7.8->9.10.11.12-> back to ->1.2.3.4->5.6.7.8-> so on, in round robin fashion, as long as cache is not expiredAlso, would appreciate update in doc that this rotate flag currently is not implemented as it was misleading.
Describe alternatives you've considered
not use caching by fixing size = 0 for ip balancing, but.. not performant
Additional context
none
@bluejekyll commented on GitHub (May 18, 2024):
yes, this would be a nice feature to add. I think it's also related to #1924, as this could be used in the forwarding hickory-dns server.
To make this accurate it would probably mean recording some stats on each RRSet and it's use in the cache, which I don't think we do today. That said, I think randomizing the order of the addresses is also something that the calling code can do. I've always been a little uncomfortable with changing RRSets from what was returned upstream, but I'm not a purest on this.
If you wanted to post something up, maybe even keeping it simple for now by just randomizing the order of the records in the result from the cache, that would be interesting to see.
@TSDevHub commented on GitHub (May 18, 2024):
Hey Benjamin, thanks for your reply :)
Ah I didn't know hickory also provided DNS server capability, I was just using it as a resolver to call DNS server.
I think having a feature where you select a random record in the DNS cache if cache item has multiple records sounds like a great start. Perhaps hickory-resolver users would find that this is good enough for their use-case with short enough TTL. And later we can add round robin.
I am new to this repo and wonder how features are prioritized and released, what is next?
@bluejekyll commented on GitHub (May 18, 2024):
we basically include things as they're ready and then publish in the next release. We're working on a new
0.25release that will probably come once we have all of the related crates that useringandrustlsupdated. So that will come as soon as some of our dependencies are updated.@bluejekyll commented on GitHub (May 18, 2024):
Something to consider when implementing this, perhaps it could be included only in the RRSet returned by the lookup function... i.e. that way it would make it something like
lookup_ip(...).await?.randomized().next()@TSDevHub commented on GitHub (May 19, 2024):
I see, then I will keep an eye on this feature request. Thanks again!
@Xuanwo commented on GitHub (Sep 11, 2024):
Hi, @TSDevHub, are you working on this now? I recently found that I need this feature and would be happy to collaborate on it.
@TSDevHub commented on GitHub (Sep 11, 2024):
Hey @Xuanwo, I am currently not working on this and been waiting for the
0.25release so it can picked up after. Good to see that more people want this feature :)As for collaboration, I am uncertain if I would be able to collaborate with you at the moment so if you want to work on it now, please feel free to start
@aajtodd commented on GitHub (Mar 7, 2025):
What is the intent of the rotate resolver option? Is it meant to work as described in this issue (i.e. if there are multiple cached entries, rotate through them on each invocation)? Looking at the code it doesn't seem to do much today, so I'm curious the original intent and what purpose it serves right now.
@djc commented on GitHub (Mar 11, 2025):
I submitted #2841 to remove the
rotateoption for now, since, as you mentioned, it doesn't do anything today. Happy to review changes that bring back similar functionality.