mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #2738] Resolver: Deduplicate connections to name servers #1056
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#1056
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 @divergentdave on GitHub (Jan 24, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2738
Is your feature request related to a problem? Please describe.
The
NameServerCacheinside the recursor may hold multiple connections to the same name server, via the same protocol, in separateRecursorPools for different zones. When shared DNS servers are used, many zones could have overlapping sets of name server IPs. This is undesirable, as it may result in many TCP connections to the same name server, wasting overhead and potentially running afoul of connection limits.Describe the solution you'd like
If we removed the
RecursorPoolencapsulation, we could separately store connections in one cache, indexed by IP and protocol, and zone name server pool information in another cache, indexed by zone name, containing a list of IPs, and possibly a list of weak references to connections. When building name server pools during recursion, instead of always constructing new connections to every name server and bundling them into a pool, we'd store the list of name server IPs and reuse or create connections to individual servers as needed.Currently,
RecursorPoolalso has a map in a mutex used to deduplicate in-flight requests to name servers of a single zone. We'd probably want to reimplement that deduplication at the zone level.Describe alternatives you've considered
Alternately, we could leave
RecursorPoolmostly intact, but share connection objects to common servers acrossRecursorPools, lazily opening connections to new name servers on demand.Additional context
This occurred to me while considering possible solutions to #2574. Adding a layer of indirection in this manner would also let us expire the metadata about a zone's pool without tearing down the connections. Once refreshed referrals are received, we could continue using the existing connections, assuming the same IP addresses are returned.
@djc commented on GitHub (Jan 24, 2025):
Agreed that the current pooling setup doesn't really make sense.
(Should this be part of #2725?)
@divergentdave commented on GitHub (Jan 29, 2025):
I think adding it to the tracking issue makes sense. I can see having many TCP connections open to common providers leading to operational problems, because of rate limiting on the authoritative side. Done.
@cpu commented on GitHub (Aug 21, 2025):
+1 to this idea. The authoritative server encrypted transport connection state metadata described by RFC 9539 also wants to be indexed by nameserver IP without consideration of zone name. I think this change would be helpful/necessary for the probing policy it describes to be implemented faithfully.
@djc commented on GitHub (Aug 22, 2025):
Will this still reuse some of the abstractions in the resolver? I think we'd want to stick with a structure like in #3210 where connections to a single server are kept together; so I don't think the recursor should split up connections to the same server again (referring to "separately store connections [..] indexed by IP and protocol"). I think the resolver's
NameServercould be that abstraction, though I wonder if the recursor won't need any of theNameServerPoolinfrastructure. I guess maybe it could build its ownPoolStatevalues?@cpu commented on GitHub (Aug 27, 2025):
@divergentdave Do you have thoughts on this & #3210 as the OP of this issue?
@divergentdave commented on GitHub (Aug 27, 2025):
Storing connections to the same server via different protocols together seems fine to me, the protocol doesn't necessarily have to be part of the map key. The resolver and the recursor will have significant overlap in the fields they store per-server, so I think it may make sense to share data types.
@marcus0x62 commented on GitHub (Oct 29, 2025):
Addressed in #3328