There is an interesting and not so well-known feature of APT package manager: the ability to automatically choose a download mirror for every individual operation.

By “mirror” I mean the URL in /etc/apt/sources.list, for example stands for official Ubuntu mirror in Switzerland. You may make a choice of a mirror during the system installation, and then it remains static, regardless of your location. In fact, you can manually switch to another mirror for the duration of stay in another country. But actually, there is a way to let the package manager to do this automatically by specifying mirror:// as the URL. The mirror:// appears to be a special protocol, which is handled internally by the recent versions of APT. Upon the action, the URL is substituted by a real URL of some mirror chosen by the backend.

The “mirror://” could have been just a mirror picker, a simple redirection. But actually it’s much cooler than that: it does sort of load balancing! So, when you update the packages lists, or install a package along with many dependencies, it will download different things from multiple mirrors simultaneously!

An ordinary source.list could be switch to mirror:// with a simple command (we will do a backup, of course):

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo sed -i -E "s|http://.*\.archive\.ubuntu\.com/ubuntu/?|mirror://|g" /etc/apt/sources.list

Now we can run apt update, and enjoy the balanced use of multiple mirrors:

$ sudo apt update
Get:6 Mirrorlist [234 B]                                                                          
Get:9 jammy-backports InRelease [99.8 kB]                                                       
Ign:7 jammy InRelease                                                                                   
Get:8 jammy-updates InRelease [114 kB]                                                                  
Get:13 jammy-security/main i386 Packages [208 kB] 
Get:14 jammy-backports/main amd64 Packages [3008 B]
Get:19 jammy-backports/main amd64 c-n-f Metadata [272 B]                           
Get:21 jammy-backports/universe amd64 Packages [6744 B]                                 
Get:22 jammy-backports/universe i386 Packages [5200 B]                                          
Get:28 jammy-backports/universe amd64 c-n-f Metadata [352 B]                                            
Get:30 jammy-security/main amd64 Packages [480 kB]                                                    
Get:31 jammy-updates/main amd64 Packages [715 kB]                                                       
Get:54 jammy-updates/multiverse i386 Packages [1708 B]

Voila. In case one mirror experiences a momentum heavy usage, the operation could finish much faster.

Credits go to this askubuntu post.