Phillip/449 iterative cache extra queries regression #452
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.
Closes #449
Context
I noticed that when querying
./zdns A google.com yahoo.com --iterative --threads=1
that we're making 2 queries to the root servers to fetch the.com
gTLD servers. This is inefficient and leads to sending a decent bit of load to the root servers unnecessarily.In my investigation, I realized the regression was caused by #413. At the time, I didn't understand what that section of code was doing and removing it both eliminated the many
SERVFAIL
errors we were seeing and improved performance. Seemed like an easy win.Well that code was attempting to prevent repeated lookups for the authorities as we're trying to do here. I'm not entirely sure why that code caused
SERVFAIL
errors, but I took it as a starting point for this PR.Description
This is only applicable to
--iterative
mode.
, next layer is.com
forgoogle.com
.com
Answers
sectionAuthorities
and lookup in the cache for theA
andAAAA
record for theAdditionals
Simple Test Case
The test case laid out in the open issue -
./zdns A google.com yahoo.com --iterative --threads=1
now passes, we only query the root servers once for two.com
domains.Performance
This means a lot more cache lookups. In the case of
.com
, there are 13 gTLD servers each with anA
andAAAA
record. This means 1 (NS record)+ 13 (A) + 13 (AAAA) = 27 cache lookups. The benefit is eliminating an unnecessary DNS lookup.To check performance, I compared against
main
and usediptables
to count the number of outgoing UDP packets to port 53. The results look very promising, 42% fewer packets sent and 20% reduction in runtime.Setup
sudo iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
- install the packet counting rulesudo iptables -L OUTPUT -v -n
- Check the number of UDP packetssudo iptables -Z output
- clear packet count7k domains, A lookups,
--iterative --threads=100
main
Phillip/449
Accuracy
Testing accuracy with the cache is a bit hard. One idea I had is that over time, the cache will become more filled up and it's less and less likely that a lookup will have to go to the wire. So it's these later lookups that have the most chance of being incorrect.
As a test, I used a domain from the
current.csv
CrUX dataset, order.starkeypro.com.The result from a single lookup for this domain -
Was identical to a lookup for this domain after 7k domains had been looked up.