[dns-operations] good async DNS library

Mark Delany b9w at charlie.emu.st
Mon Apr 29 21:27:49 UTC 2019


On 29Apr19, Tony Finch allegedly wrote:
> John Levine <johnl at taugh.com> wrote:
> >
> > I've done DNS queries in 100 threads in parallel on a not particularly
> > fast server with no trouble.  I could probably run more but that was
> > enough for my application.
> 
> DNS is a really good protocol for exercising the concurrency performance
> of a networking library. It is so lightweight (in the happy path) that
> library overhead dominates.

It's also the cost of context switching: issuing a syscall for every coupla
hundred bytes of data is an obvious performance killer. It doesn't help that the
UDP stack on mainstream OSes hasn't had the love that TCP has. (I occasionally
mumble that QUIC may be the best thing that's ever happened to DNS performance
simply because of the love that UDP might get.)

If you want the highest performance out of your DNS library then you'll want one
that lets you intercept or replace the I/O layer so as to batch the messages
with, e.g., sendmmsg()/recvmmsg(). Or better yet netmap since the *mmsg() code
is often just an iteration over *msg() calls. I note that c-ares supports I/O
interception so batching below that library might be possible.

Batching turns a typical 2-4 syscalls/query rate to something confortably below
1.0 syscalls/query. And the beauty is the busier the system the more efficient
it gets! I've seen orders of magnitude reduction in syscalls/query and, at least
in my experience, that's the only way to get anything approaching line-rate DNS.


Mark.



More information about the dns-operations mailing list