Increase package download speed using DNF package manager in RPM-based systems

If you’re experiencing slow package downloads or updates, here is a workaround to speed up DNF package manager in AlmaLinux and Rocky Linux.

This guide is officially tested in Almalinux 9, however it should work in all RHEL-based systems that uses DNF as their default package manager.

Introduction

As you already know, DNF is the default package manager for AlmaLinux 8/9, and Rocky Linux 8.

The other day I decided to try Almalinux 9. I downloaded the Almalinux 9 iso and run it with a kvm vps. The first thing I noticed after trying Almalinux 9 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 AlmaLinux and Rocky Linux

We can increase the download speed while installing packages using the DNF package manager by increasing the maximum number of simultaneous package downloads.

To do so, edit /etc/dnf/dnf.conf file:

sudo nano /etc/dnf/dnf.conf

Add the following line to enable DNF parallel downloads:

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.

Choose fastest mirror

The another option to speed up DNF is to select fastest mirror from the 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 Almalinux 9 virtual machine.

In my experience, DNF takes longer time to download metadata than to download a package. This is because Almalinux’s 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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here