chriscrowe / docker-pihole-unbound

Run Pi-Hole + Unbound on Docker
1.04k stars 270 forks source link

Unbound cache is lost upon container restart #217

Open preethamvishy opened 11 months ago

preethamvishy commented 11 months ago

When the pihole-unbound container is recreated/restarted, unbound appears to be building cache from scratch and there's a high number of cache misses compared to cache hits. Since you really reap the benefits of unbound's cached DNS resolution once the cache builds up, a restart of the container for any reason appears to undo the cache built up.

Is there a way to persist the unbound cache across restarts?

total.num.queries=584
total.num.queries_ip_ratelimited=0
total.num.cachehits=57
total.num.cachemiss=527
total.num.prefetch=2
total.num.expired=0
total.num.recursivereplies=527
total.requestlist.avg=3.0794
total.requestlist.max=44
total.requestlist.overwritten=0
total.requestlist.exceeded=0
total.requestlist.current.all=0
total.requestlist.current.user=0
...
time.up=883.899163
time.elapsed=883.899163
burnbabyburn commented 11 months ago

By default unbound stores cache in memory and thus it's normal to loose cache on restart. You need cachedb as described in the unbound documentation and ofc need a seperate docker volume to store unbound cachedb or an additional redis container. If you want to change default behaviour, you would have to invest some time (especially for the 2 container version in this repo)

But LMGTFY Check if unbound has been compiled with --enable-cachedb Setup cachedb config with or without redis backend - official documentation