I have a weird problem, I have a server running headless Ubuntu 20.04, and I have setup SSH access local only via PuTTY, but when I open PuTTY and connect to the server, and after I've entered the login details, as soon as I press enter to enter my password, it takes about 3-5 minutes for the command prompt to appear, simple command like clear, works fast, but when I upgrade by using apt get upgrade, normally it would be fast with the status bar at the bottom moving really fast, but recently (in the last week or so), that status bar has been moving really slow, and when apt starts fetching files for upgrading, the fetching is also very slow, but the downloads are vey fast, it seems there's a huge time delay between when apt fetches a file and when it unpacks it.
at one point when there was some upgrades, there was only some library files and PHP related files, around 15 files in total, it took 15 minutes for the status bar to finish and the command prompt returns, but if I were to reboot the server, everything runs really quickly, then somewhere within a week it slows down.
How can I tell what's causing the server to suddenly start crawling?