Pihole lookups sometimes extremely slow (5-10s)

Expected Behaviour:

Consistent fast lookups.

Actual Behaviour:

Pihole lookups are sometimes very slow and taking up to 10 seconds. This also happens on sites that i visit frequently and would assume to be cached. The times for lookups in pihole log show around 8 to 20ms however site loading in Firefox is taking forever.
Pihole is running on a pi4, fresh install.

Example from my PC:

time dig fonts.gstatic.com @192.168.0.248

; <<>> DiG 9.16.0 <<>> fonts.gstatic.com @192.168.0.248
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27358
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;fonts.gstatic.com.             IN      A

;; ANSWER SECTION:
fonts.gstatic.com.      253     IN      CNAME   gstaticadssl.l.google.com.
gstaticadssl.l.google.com. 168  IN      A       172.217.22.35

;; Query time: 9 msec
;; SERVER: 192.168.0.248#53(192.168.0.248)
;; WHEN: Di Mär 03 20:11:10 CET 2020
;; MSG SIZE  rcvd: 98

dig fonts.gstatic.com @192.168.0.248  0,01s user 0,01s system 0% cpu 5,027 total

Debug Token:

https://tricorder.pi-hole.net/nvvoliummd

Your debug log is normal.

This would tend to indicate that there is a setting in the browser that is controlling this behavior. Have you cleared the browser cache and restarted the browser as a start? Do you see similar slow page loads to the same URL's from other browsers and/or different clients and browsers?

I have tried different browsers and clearing cache (chrome, brave) with the same results. The slowdowns also seem rather random to me. For example I might visit a site, it loads fast. Then i open the same site in another tab and it takes 10 seconds.

Lookups report at ~9msec but it takes 5 seconds for the results to show.

time dig github.com @192.168.0.248

; <<>> DiG 9.16.0 <<>> github.com @192.168.0.248
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50233
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1452
;; QUESTION SECTION:
;github.com.                    IN      A

;; ANSWER SECTION:
github.com.             28      IN      A       140.82.118.3

;; Query time: 9 msec
;; SERVER: 192.168.0.248#53(192.168.0.248)
;; WHEN: Di Mär 03 21:18:58 CET 2020
;; MSG SIZE  rcvd: 55

dig github.com @192.168.0.248  0,01s user 0,01s system 0% cpu 5,027 total

time dig manjaro.org @192.168.0.248      

; <<>> DiG 9.16.0 <<>> manjaro.org @192.168.0.248
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57433
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;manjaro.org.                   IN      A

;; ANSWER SECTION:
manjaro.org.            1360    IN      A       176.9.38.148

;; Query time: 0 msec
;; SERVER: 192.168.0.248#53(192.168.0.248)
;; WHEN: Di Mär 03 21:17:43 CET 2020
;; MSG SIZE  rcvd: 56

dig manjaro.org @192.168.0.248  0,00s user 0,01s system 0% cpu 5,020 total

Both of those show less than 1 second for actual time. The latter, coming from cache with an instantaneous Query time, taking no user time and less than 1 second system time. I think a better route for you would be to contact the manjaro support to find out more. Pi-hole is responding as fast as it should.

It is very curious indeed. Total time shows 5 seconds which is exactly how long it takes. Without pihole and using my modem/router as DHCP with ISP DNS there is zero issues.
I am using pihole as DHCP since the modem won't let me change DNS settings.

Thank you very much for the article! Learned something.
System is a quad core with 32gb running off an SSD and kinda idle while doing these tests. Network traffic is close to zero as well.

Dug out an old Laptop for further testing and it appears that the problem is indeed with the PC. Thank you very much for your help.

1 Like

Some additional information, perhaps someone has an idea what could be causing this.

Here is a comparison of 10 digs from the PC, first block with ISP DNS, the second with pihole queries.
CPU load on ISP is lower and consistent.
Queries to pihole are faster at a higher load but seem to throw 0% load and slow queries every now and then.

ISP:
dig github.com  0,00s user 0,01s system 25% cpu 0,033 total
dig github.com  0,01s user 0,00s system 26% cpu 0,053 total
dig github.com  0,01s user 0,00s system 55% cpu 0,023 total
dig github.com  0,01s user 0,00s system 44% cpu 0,029 total
dig github.com  0,01s user 0,00s system 59% cpu 0,024 total
dig github.com  0,00s user 0,00s system 38% cpu 0,016 total
dig github.com  0,01s user 0,00s system 19% cpu 0,030 total
dig github.com  0,01s user 0,00s system 55% cpu 0,021 total
dig github.com  0,01s user 0,00s system 43% cpu 0,028 total
dig github.com  0,01s user 0,00s system 50% cpu 0,026 total
Pihole:
dig github.com @192.168.0.248  0,01s user 0,00s system 0% cpu 5,016 total
dig github.com @192.168.0.248  0,01s user 0,01s system 94% cpu 0,015 total
dig github.com @192.168.0.248  0,01s user 0,01s system 95% cpu 0,013 total
dig github.com @192.168.0.248  0,01s user 0,00s system 96% cpu 0,018 total
dig github.com @192.168.0.248  0,01s user 0,00s system 94% cpu 0,009 total
dig github.com @192.168.0.248  0,00s user 0,00s system 91% cpu 0,007 total
dig github.com @192.168.0.248  0,01s user 0,00s system 0% cpu 5,008 total
dig github.com @192.168.0.248  0,02s user 0,00s system 96% cpu 0,017 total
dig github.com @192.168.0.248  0,01s user 0,01s system 0% cpu 5,032 total
dig github.com @192.168.0.248  0,01s user 0,01s system 91% cpu 0,015 total

Success!
After more testing i noticed packetloss between the raspberry pi and my ISPs "Connect Box" modem/router.

Ultimately the solution was found here: https://www.raspberrypi.org/forums/viewtopic.php?t=253337

Apparently the Connect Box and Pi4 do not want to play nice. Purchasing a cheap Netgear switch and hooking it between the Connect Box and the Pi remedied the issue. Net is blazing now :grin:

Switch used: Netgear GS305v3

1 Like

Very interesting!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.