Eliminate unnecessary encoding of TXT records when they will not be put into the final DNS response #5271
Labels
theme/dns
Using Consul as a DNS provider, DNS related issues
theme/performance
Performance benchmarking or potential improvement
type/bug
Feature does not function as expected
Milestone
The fix for issue 4354 in PR 4362 had some unintended consequences that cause an increase in CPU utilization of Consul's DNS server.
TXT recording encoding was changed to be done unconditionally in
formatNodeRecord
and then returned so that callers could determine whether to place them in the additional section or the answer section of the response.In many cases these records are simply discarded. In those cases we are still paying the penalty of generating them which happens to involve quite a bit of regular expression work to encode the key/value TXT records.
The solution is to determine if those TXT records would be used at all and simply not generate them in the first place. This should produce a minor reduction in CPU cycles of each DNS request with results that include node metadata. While a relatively small per request overhead, on agents with high DNS request rates the aggregate CPU utilization would be noticeable.
The text was updated successfully, but these errors were encountered: