HIRO GEAR
インフラ DNS AdGuard

Optimisation des requêtes parallèles d'AdGuard Home : accélération de la résolution DNS du réseau domestique par un facteur 80

Optimisation des requêtes parallèles d'AdGuard Home : accélération de la résolution DNS du réseau domestique par un facteur 80

I have a fiber optic connection, and physical pings to my router and the internet are extremely good at around 5ms. However, I was bothered by the phenomenon where “the browser hangs for about a second when opening a site visited for the first time.”

Upon investigating, I discovered an unexpected pitfall in the settings of AdGuard Home, which serves as both my ad blocker and DNS cache server at home.

The Real Bottleneck: The fastest_addr Trap

AdGuard Home offers several modes for upstream DNS queries. One of them is fastest_addr (Fastest IP Selection).

“One might think that selecting the fastest IP is nothing but a blessing,” but this was actually the root cause.

  • Behavior of fastest_addr: For every IP address returned by name resolution, AdGuard itself sequentially sends ping or TCP connection tests to select the fastest one and return it to the client.
  • The Problem: Servers that do not respond to pings or overseas hosts cause the response to the client to be completely blocked until the timeout (default 1 second) is reached.

In actual measurements, queries to uncached domains took as much as 1,020ms (over 1 second).

Solution: parallel (Parallel Requests) and Optimistic Caching

I completely overhauled the settings as follows:

  1. Changed the query mode to parallel: Queries are sent simultaneously to multiple upstream DNS servers (Cloudflare, Google, Quad9), and the first response received is immediately adopted.
  2. Added the fastest domestic Cloudflare DoH as an upstream: Placed https://cloudflare-dns.com/dns-query at the top of the list.
  3. Enabled cache_optimistic: true (Optimistic Caching): Even if a record’s TTL has expired, it immediately returns the previous cache with 0ms latency while updating asynchronously in the background.

[!TIP] By setting the minimum TTL (cache_ttl_min) to 300 seconds (5 minutes), you can prevent frequent queries caused by the common “30-second expiration” seen on recent CDNs.

Results: From 1,020ms to 10ms

After applying the settings, query times for uncached domains dramatically improved to 10ms–15ms (an 80-fold speedup).

Not only does daily web browsing feel smoother, but the responsiveness of git clone and npm install in the terminal has also significantly improved, greatly enhancing network transparency.