DEV Community

Cover image for Simultaneous Downloads with aria2 for Maximum Speed | Advanced Tutorial
Ernesto Emilio Villaran G
Ernesto Emilio Villaran G

Posted on

Simultaneous Downloads with aria2 for Maximum Speed | Advanced Tutorial

In the era of mass digitalization, where downloading multi-gigabyte files has become a daily task, the frustration of facing slow speeds and seemingly endless downloads is a universal problem. While most users settle for basic browsers or obsolete download managers, there is a tool in the power users' arsenal that completely transforms this experience: aria2. This article is not just an introduction; it is a deep dive into how to leverage the power of simultaneous downloads with aria2 to maximize your internet connection, organize your transfers efficiently, and become a master of download management on Linux and any other operating system.

Why is aria2 the Best-Kept Secret of Advanced Users?

Aria2 is much more than a simple command-line download client. It is a lightweight, open-source, multi-protocol download utility that supports HTTP/HTTPS, FTP, SFTP, BitTorrent, and Metalink. But its most revolutionary feature, and the one we will focus on, is its ability to perform segmented and simultaneous downloads.

Unlike a web browser that downloads a file by establishing a single connection to the server, aria2 can split the file into multiple segments and download them all at the same time through parallel connections. This is especially useful when servers limit the speed per individual connection. By establishing 5, 10, or even 16 simultaneous connections to the same file, you can effectively saturate your bandwidth, drastically reducing the total download time. This technical approach can turn a one-hour download into a process of just a few minutes.

Key Advantages of Using aria2 for Simultaneous Downloads:

Accelerated Download Speed: Splitting files into parallel segments is the most effective speed multiplier.

  • Efficient Recovery: Automatically resumes interrupted downloads, even after a system shutdown.

  • Minimal Resource Consumption: It is incredibly lightweight compared to graphical download managers.

  • Total Flexibility: It is controlled via commands, making it perfect for scripting and automation.

  • Source Versatility: It can handle everything from a simple HTTP link to a complex list of torrents.

Installing aria2 on Your System

The first step to unlocking this power is to install the tool. The process varies slightly depending on your operating system.

On Debian/Ubuntu-Based Linux Distributions:

sudo apt update && sudo apt install aria2
Enter fullscreen mode Exit fullscreen mode

On Arch-Based Linux Distributions:

sudo pacman -S aria2
Enter fullscreen mode Exit fullscreen mode

On macOS (using Homebrew):

brew install aria2
Enter fullscreen mode Exit fullscreen mode

On Windows:

Download the binary executable from the official aria2 website and add it to your PATH, or use a package manager like Chocolatey:

choco install aria2.
Enter fullscreen mode Exit fullscreen mode

You can verify the installation by executing in your terminal:

aria2c --version
Enter fullscreen mode Exit fullscreen mode

Advanced Configuration: The Key Parameters for Simultaneous Downloads
The magic of aria2 lies in its command-line parameters. Mastering these flags is the key to transforming your download experience.

The Fundamentals: Basic Download Command
A simple aria2 command looks like this:

aria2c "https://example.com/large-file.zip"
Enter fullscreen mode Exit fullscreen mode

This will download the file, but sequentially, without leveraging its true potential. To activate the multi-segment mode, we need the advanced parameters.

Essential Parameters for Simultaneous Downloads:

-x or --max-connection-per-server:
Enter fullscreen mode Exit fullscreen mode

Function: Sets the maximum number of connections per server for one download.

Usage:

-x 16
Enter fullscreen mode Exit fullscreen mode

or

--split:
Enter fullscreen mode Exit fullscreen mode

Function: Defines how many segments the file will be split into for downloading.

Usage:

-s 16
Enter fullscreen mode Exit fullscreen mode

will split the file into 16 independent segments.

Recommended Value: Usually equal to the number of connections

(-x)
Enter fullscreen mode Exit fullscreen mode

For example:

-s 16 -x 16
Enter fullscreen mode Exit fullscreen mode
-j
Enter fullscreen mode Exit fullscreen mode

or

max-concurrent-downloads
Enter fullscreen mode Exit fullscreen mode

Function: Controls the maximum number of different files that can be downloaded at the same time.

Usage:

-j 5
Enter fullscreen mode Exit fullscreen mode

Allows you to download 5 different files simultaneously, each with its own segmented connections.

Recommended Value: Depends on your CPU and bandwidth. Start with 3-5.

Advanced Example Command:

A command that makes the most of your connection could be:

aria2c -x 16 -s 16 -j 5 "https://example.com/file1.zip" "https://example.com/file2.zip"
Enter fullscreen mode Exit fullscreen mode

his command will download two files at the same time (-j 2), and each of them will use 16 parallel connections (-x 16 -s 16).

Step-by-Step Guide: Configuring Simultaneous Downloads with aria2

Step 1: Environment Analysis and Speed Test
Before launching dozens of connections, run a speed test to know the maximum limit of your download bandwidth. This will help you calibrate the values for -x and -s. There is no point in setting up 100 connections if your maximum speed is 100 Mbps; 16 is usually more than enough.

Step 2: Creating a Persistent Configuration File
Writing long parameters in every command is inefficient. Create a configuration file in:

~/.aria2/aria2.conf
Enter fullscreen mode Exit fullscreen mode

and define your default options. As suggested in the LinuxMind guide on simultaneous downloads with aria2, here is an example of an optimal configuration:

# Advanced aria2 Configuration - ~/.aria2/aria2.conf

# Connection limit per server
max-connection-per-server=16
# Number of splits per file
split=16
# Concurrent downloads (different files)
max-concurrent-downloads=5

# Performance and Stability Options
min-split-size=1M
stream-piece-selector=geom
# Enable automatic resumption
continue=true
max-tries=5
retry-wait=10

# Speed Limits (adjust according to your connection)
# max-overall-download-limit=0 (0 = unlimited)
# max-download-limit=0

# File and Directory Options
dir=~/Downloads
save-session=~/.aria2/session.txt
input-file=~/.aria2/session.txt
save-session-interval=60

# HTTP/FTP Configuration
http-accept-gzip=true
user-agent=aria2/1.36
Enter fullscreen mode Exit fullscreen mode

With this file, your command is greatly simplified:

aria2c --conf-path=~/.aria2/aria2.conf "YOUR_LINK_HERE"
Enter fullscreen mode Exit fullscreen mode

Step 3: Real-Time Verification and Monitoring
When you start a download, aria2 will display a real-time interface with detailed statistics for each segment. Pay attention to this output; it will allow you to identify bottlenecks. If you see many segments stalling, it might be that the server is limiting concurrent connections and you should reduce the value of -x.

Top comments (0)