If you're experiencing slow package downloads or updates, here is a workaround to speed up DNF package manager in Fedora and other RPM-based systems such as RHEL and CentOS that uses DNF as their default package manager.
As you already know, DNF is the default package manager for Fedora 25 and newer versions, RHEL 8 and its clone CentOS 8. The other day I decided to try Fedora 33. I downloaded the Fedora 33 Vagrant box and run it with Oracle Virtualbox. The first thing I noticed after trying Fedora 33 is that the DNF package manager is terribly slow. I thought DNF might perform slow when it updates the repositories and metadata for the first time. But, it was still slow in the subsequent times. After a couple web searches, I found a solution that worked for me.
Speed Up DNF Package Manager In Fedora, RHEL, CentOS
We can speed up DNF package manager by increasing the maximum number of simultaneous package downloads.
Edit /etc/dnf/dnf.conf
file:
$ sudo nano /etc/dnf/dnf.conf
Add the following line:
max_parallel_downloads=10
This option tells the DNF to use 10 parallel downloads at the same time. You can increase or decrease this value as per your wish. The default value for max_parallel_downloads
option is 3. Press CTRL+O
to save the changes and press CTRL+X
to exit.
Now try to perform any package operation with DNF command. You will notice the speed difference while downloading the packages.
The another option to speed up DNF is to select fastest mirror from the Fedora public mirrors. To do so, again edit the /etc/dnf/dnf.conf
file:
$ sudo nano /etc/dnf/dnf.conf
Add the following line:
fastestmirror=True
Press CTRL+O
followed by CTRL+X
to save the file and exit.
Now I can see a noticeable difference when installing and updating packages with DNF in my Fedora 33 virtual machine.
In my experience, DNF takes longer to download metadata than to download a package. This is because Fedora metadata is larger than the other package manager's. So I guess DNF is slow only when updating the repository metadata. After that, it works smoothly.
Hope this helps.
Related read: