Add option to delay Pi-Hole DNS response

I'm seeing multiple questions about running multiple Pi-Holes and on how to get all the DNS statistics in one place.

Given that most clients pick the fastest server from the list they are provided, if a Pi-Hole could delay the DNS response for a user chosen number of milliseconds it should be possible to steer clients to a faster responding Pi-Hole.

If we could have a command line option, maybe -s or --sleep, followed by a number of milliseconds, then users could set the Pi-Hole they want for redundancy to wait before that long before responding, thus steering clients to the one they want as primary.

If the primary should fail this would impose the selected delay on all queries but it should be almost unnoticeable for the short delays likely to be needed.

Are you sure the system will always pick the faster one? This seems to make sense but I'm not sure this is what really happens. Adding artificial delay can cause your Pi-hole to become stale altogether. Assume you want to add 100msec to each query. When there are more then 10 queries per second coming in, this will create a heavy backlog that may never be able to get cleared.

I'd guess that not all clients follow the "pick the fastest server" approach to DNS servers, all of the devices I have access to do seem to do that though.

Adding an artificial delay should be no worse that picking a slower responding upstream DNS server. Would 100 ms even be needed, I'd guess even 10 ms would be enough.

I didn't consider very busy setups, but if the delay does cause problems the user could reduce the delay or eliminate it by restarting Pi-Hole.

I'm not in favor of such a feature. Adding delays that are in effect at all times, just for the purpose of nudging queries to one Pi-hole or another, is not attractive.

And the only potential benefit is to have all the stats in one place. There are other solutions that can do that - I don't think adding delay to Pi-hole is the correct solution.

1 Like

Please don't add such a feature. I can see catastrophic delays coming towards us. I wouldn't consider

to be

In contrast, if you pick only 10msec, this may be too low. Assume your Pi-hole doesn't know about the domain and has to ask upstream. The latency to the web can be large enough to compensate for your artificial 10 msec. My typical latency to a trustworthy DNS provider is on the order of 80-90 msec.

Yes, I live in a more rural area, latencies of 20 msec and less are typically only achievable when living in large cities with big backbone connections and maybe even ten only when you have a fiber hub close to you. I'm sure this isn't the case for most.

So I'd also see this feature rather on the order of 100msec if you want it to work. This puts the hard limit of 10 queries per second. When my Android phone connects to the Wi-Fi, it quickly sends out several dozens of queries to Google, podcast servers, etc. (depending on your apps). I have seen worse with iPhones.

I wouldn't want the connecting of a mobile phone to my Wi-Fi to tear down my name resolution for 20 seconds or so.

In contrast, I'm running a Pi-hole for almost 3 years now and have never ever had a single fail. I bought a very good powerbank some years back which can power the Raspberry Pi for almost an entire day (5V, 10,000mAh). I have it connected to the power grid and run the Pi-hole off the battery 24/7. Never had a single power issue (or any other fail).

Maybe what you want is not necessary. I typically see routers die more often than a Pi-hole does.

Closing as duplicate of