]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Speed up cache hits by skipping the LB policy when possible
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 26 Aug 2025 12:00:26 +0000 (14:00 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 9 Oct 2025 12:01:20 +0000 (14:01 +0200)
commit059bd0e22be0680a87bdad09c687ba0fe65e2dbb
treeca61f7ce56c662bf44b8260202c333cc5a944cfe
parent28c6baf980aa762ae1a533674df1d47b4031b261
dnsdist: Speed up cache hits by skipping the LB policy when possible

We use to execute the load-balancing policy to select a backend before
doing the cache lookup, because in some corner cases the selected
backend might have settings that impact our cache lookup. In practice
most configurations have a consistent set of settings for all servers
in a given pool, so it makes no sense to waste CPU cycles selecting a
backend if we are going to get a hit from the cache.
This PR adds a bit of code to check if a pool is in a consistent state,
and if it is it delays the execution of the load-balancing policy to
after the cache lookup, skipping it entirely for cache hits.

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-backend.cc
pdns/dnsdistdist/dnsdist-lbpolicies.hh
pdns/dnsdistdist/dnsdist-lua-bindings.cc
pdns/dnsdistdist/dnsdist-server-pool.hh
pdns/dnsdistdist/dnsdist-settings-definitions.yml
pdns/dnsdistdist/dnsdist.cc
pdns/dnsdistdist/docs/reference/config.rst
regression-tests.dnsdist/test_Caching.py