Pi-hole is slow or sometimes doesn't even get DNS requests

Expanding on previous post, I've been testing atop the last few hours and it should be able to get to the bottom of it for you.

Install atop on your Pi-hole

$ sudo apt update
$ sudo apt install atop

This will install it and also add a logging service which should auto-start. The service writes process info covering 10 minute intervals and for a rolling 28 days by default. These can be changed but should be fine for your needs for now. Check the service is running – should be loaded, active and running.

$ systemctl status atop

Wait 15 minutes then check that a log is being created. Should be a file like atop_20221108. There's a new file created each day for 28 days.

$ cd /var/log/atop
$ ls -l

Load today's file into atop to inspect. Using the example above:

$ atop -r atop_20221108

At the very top of the screen in the black border you can see the interval currently being displayed. Skip forwards with t. Skip backwards with T. Reset with r.

Press p to toggle on CPU consumption per program. Now you can use t to skip forward and see which programs were dominating the CPU in each 10 minute period.

It can show a load of other things – if you get lost in the interface, press q to quit then up arrow to reload the command and go again.

Final step – leave it running for a while and hopefully you'll have some of these high load situations. Now you can run the command above and inspect the log and see what's causing it.

You can also run atop interactively. Just run atop by itself and it shows live data covering 10 second intervals. In this screen you can use the same commands to look at things like CPU, memory, command lines – check the manual with man atop.