[systemd-devel] systemd-resolved: performance question
Robert Ayrapetyan
robert.ayrapetyan at gmail.com
Tue Mar 14 18:25:01 UTC 2023
Hello, I'm using systemd-resolved on the server which performs a lot
of DNS queries (~20K per second) and systemd-resolved helps a lot
providing a cache:
Cache
Current Cache Size: 263
Cache Hits: 30928976
Cache Misses: 2961
However, systemd-resolved process almost constantly utilizes 100% of
CPU (I don't have any other dns services like dnsmasq installed).
strace shows this:
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
48.73 0.966765 4 194141 stat
15.06 0.298804 12 24106 sendmsg
13.59 0.269703 8 32346 32346 openat
6.42 0.127381 5 24118 recvmsg
5.49 0.108829 4 24118 recvfrom
5.34 0.106037 4 24118 epoll_wait
5.33 0.105838 4 24118 gettid
0.01 0.000151 6 24 epoll_ctl
And in particular for stat, it queries just 3 files in a loop:
stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=738, ...}) = 0
<0.000010>
stat("/run/systemd/resolve/resolv.conf", {st_mode=S_IFREG|0644,
st_size=624, ...}) = 0 <0.000009>
stat("/run/systemd/resolve/stub-resolv.conf", {st_mode=S_IFREG|0644,
st_size=738, ...}) = 0 <0.000013>
My question is: why does it "stats" so often? Is this a result of my
misconfiguration?
/etc/systemd/resolved.conf:
...
FallbackDNS=1.1.1.1 1.0.0.1
/etc/nsswitch.conf:
...
hosts: resolve [!UNAVAIL=return] files dns
More information about the systemd-devel
mailing list