You are not logged in.

#1 2021-08-29 11:18:00

jetten
Member
Registered: 2015-02-28
Posts: 6

systemd-resolved much faster after removal of extra DNS servers

I want to share my findings on how systemd-resolved behaves when there are multiple DNS servers configured.

The problems started when I switched to a new ISP. I noticed that web browsing was horribly slow, seems that it is mostly caused by the ISP:s DNS servers assigned from DHCP are not very quick to respond.

I assumed the DNS slowness could easily be remedied by installing caching nameserver systemd-resolved on my system, but it turned out it made almost no difference. Checking `resolvectl statistics` revealed that systemd-resolved cache was usually below 20 entries. So the question is, why is the cache utilization so low?

Turns out it is caused by systemd-resolved flushing its caches each time it switches to an alternate DNS server. My ISP assigns 4 different DNS servers through DHCP (two IPv4 + two IPv6). Systemd-resolved will pick one of those nameservers to use for requests, but if the response is delayed (because ISP:s nameservers are slooow), systemd-resolved will switch to an alternate nameserver, and at the same time flush its cache. I noticed that during heavy use of the web browser, systemd-resolved could be switching nameservers as often as every 3-5 seconds, causing the cache to be flushed at the same intervals.

The solution was of course to configure DNS servers manually, making sure to configure only one DNS server for systemd-resolved to use, so that it can't switch nameservers back and forth. Now when checking `resolvectl statistics`, it is showing a cache size of several hundred items, instead of only tens of items as before removing the extra nameservers.

Are other people also affected by the same? I presume most users might have a caching nameserver in their CPE or router, and therefore are not affected. But there must still be a significant amount of users who have a similar situation as me, where the CPE does not have a caching nameserver and they are using the ISP:s nameservers directly. Also I would assume some users have configured their computer to use either Google or Cloudflare DNS directly with redundant IP addresses (8.8.8.8 + 8.8.4.4 and 1.1.1.1 + 1.0.0.1 respectively), these users might also encounter the same issues with caching as I am. To test for yourself, try running in a terminal while browsing around some websites: `watch resolvectl statistics`. Do you at some point notice that the cache size drops to almost zero suddenly, or is the cache size stable?

Offline

#2 2021-08-29 12:23:38

ratcheer
Member
Registered: 2011-10-09
Posts: 912

Re: systemd-resolved much faster after removal of extra DNS servers

Thanks for this. I have been experiencing slow web page loads, even though my internet connection is pretty fast (speed tests usually around 445/23 mbps). I will try your suggestion.

Offline

Board footer

Powered by FluxBB