My APT Update is Slow / How to Optimize APT Update

It is possible that your VPSes APT package manager is selecting an incorrect or far away mirror for update, for example, a VPS in Frankfurt, Germany may end up selecting a mirror from Australia due to GeoLocation related issues, this does not mean the VPS is slow, but the mirror selected is simply too far away!

Which inturn can lead to slow APT update process due to an incorrect or simply too far away mirror being selected,

note the "au.archive.ubuntu.com" seen in the update message, this implies that the Australian mirror is being selected instead of a closer mirror,

root@vps:~# apt update
Hit:1 http://au.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://au.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB
Get:3 http://au.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://au.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://au.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,702 kB]
........
....
Get:31 http://au.archive.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [20.7 kB]
Get:32 http://au.archive.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5,196 B]
Get:33 http://au.archive.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [500 B]
Fetched 8,133 kB in 6s (1,354 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
83 packages can be upgraded. Run 'apt list --upgradable' to see them.

The simple fix for this is to edit

/etc/apt/sources.list

and remove the word au. from any domain name you see,

for example

deb http://au.archive.ubuntu.com/ubuntu focal main restricted

becomes,

deb http://archive.ubuntu.com/ubuntu focal main restricted

Now lets re-run apt update after running apt clean,

root@vps:~# apt update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [970 kB]
........
....
Get:47 http://archive.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5,196 B]
Get:48 http://archive.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [500 B]
Fetched 24.2 MB in 2s (11.6 MB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
83 packages can be upgraded. Run 'apt list --upgradable' to see them.

We see a much higher speed being achieved now compared to earlier and also faster APT experience with this run completing in just 2 seconds while the previous run took 6 seconds.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS