Guide

aria2 speed & BitTorrent optimization

Which settings really make aria2 faster, measured rather than guessed. We timed every setting on this page with aria2 1.37.0, so you can see how much each one helps and when it stops helping.

Last updated: Tested with aria2 1.37.0

The short version

Put this in aria2.conf and most HTTP and FTP downloads run as fast as the server and your line allow. The rest of the page explains each line and what to do when it is not enough.

aria2.conf — fast HTTP/FTP
max-concurrent-downloads=5
max-connection-per-server=16
split=16
min-split-size=1M
file-allocation=falloc
disk-cache=64M
continue=true
max-tries=5
retry-wait=5

Every line was loaded by aria2 1.37.0 with no warnings. Comments must go on their own line: aria2 refuses to start on "split=16 # comment".

  • 10.6×faster with 12 connections than with aria2's default of 1, on a server that limits each connection
  • 5.4×slower when min-split-size is 20M (the default) instead of 1M on a 50 MB file
  • +7 %time when we asked for 16 connections from a server that allows 4: more is not always better

Where download speed comes from

A slow download is almost always one of four limits. Find yours first; each one has a different fix.

  1. 01

    The server limits each connection

    Many servers and CDNs cap how fast one connection can go. aria2's answer is more connections to the same file.

    max-connection-per-server, split
  2. 02

    Your line is full

    Once you reach your plan's speed, nothing in aria2 makes it faster. More connections only add overhead.

    Nothing to tune: you are done
  3. 03

    The disk cannot keep up

    A slow hard drive, an SD card or a network share can cap speed below your line, especially with many small writes.

    file-allocation, disk-cache
  4. 04

    BitTorrent has too few peers

    A torrent is only as fast as the peers you can reach. No open port and dead trackers mean few peers.

    listen-port, bt-tracker, DHT

More connections: how much they help

We downloaded the same 50 MB file with 1 to 16 connections from a test server that limits each connection to 2 MiB/s and the whole line to 24 MiB/s.

Download speed by number of connectionsaria2 1.37.0, -x N -s N -k 1M, 50 MB file. Measured, one run each.
Show the numbers
ConnectionsMiB/sResult
12.01 connections: 2.0 MiB/s, 24.1 s
23.92 connections: 3.9 MiB/s, 12.2 s
47.74 connections: 7.7 MiB/s, 6.2 s
814.88 connections: 14.8 MiB/s, 3.2 s
1221.012 connections: 21.0 MiB/s, 2.3 s
1620.816 connections: 20.8 MiB/s, 2.3 s

Speed grows almost exactly in step with connections (1 → 2 → 4 → 8 doubles each time) until the line is full. Between 12 and 16 connections nothing changes, because the line, not the server, is now the limit. On a real server the per-connection limit is unknown, so 16, aria2's maximum, is a sensible start: when the line is the limit, extra connections cost almost nothing.

min-split-size: the setting that quietly slows you down

aria2 never splits off a piece smaller than min-split-size, so a file needs to be large before it gets many connections. The default is 20M. Same server, same 50 MB file, 16 connections allowed:

Download time by min-split-sizearia2 1.37.0, -x 16 -s 16, 50 MB file. Lower is better.
Show the numbers
min-split-sizeSecondsResult
1M2.3-k 1M: 2.3 s
5M3.2-k 5M: 3.2 s
10M6.2-k 10M: 6.2 s
20M12.2-k 20M: 12.2 s

With the default 20M, aria2 used only two connections on this file and took 12.2 seconds instead of 2.3. For files of a few hundred megabytes or less, set min-split-size=1M. For multi-gigabyte files the default is fine, because there is enough data for 16 pieces anyway.

When more connections stop helping

Two more measurements, with the same file and server settings.

SituationResultWhat to do
A server that accepts only 4 connections-x 4: 6.2 s · -x 16: 6.7 sExtra connections are refused and retried, which costs a little time. If you see 503, 429 or 403 errors, lower -x to what the server allows.
The same file on two hosts (a mirror)one host: 12.2 s · two hosts: 6.2 s (both -x 2)max-connection-per-server counts per host, so a mirror doubles the connections you may open. Give aria2 every mirror URL for the same file on one line.

aria2 treats several URLs on one command line as sources for the same file: aria2c URL1 URL2. In an input file, put them on one line separated by a tab.

BitTorrent: speed comes from peers

For torrents, connections per server do not matter. What matters is how many peers can find you and how many you can find.

  1. 01

    Open one port, and fix it

    By default aria2 picks a random port between 6881 and 6999, which you cannot forward. Set listen-port (TCP) and dht-listen-port (UDP, also used for UDP trackers) to one number and forward both protocols on your router. Peers can then connect to you, not only you to them.

  2. 02

    Add live trackers

    Many torrents carry dead trackers. A fresh bt-tracker list from the tracker list is often the difference between 0 peers and hundreds.

  3. 03

    Keep DHT and peer exchange on

    They find peers without any tracker. They are on by default; aria2 turns them off by itself for torrents marked private.

  4. 04

    Allow more peers on fast lines

    bt-max-peers is 55 per torrent by default. On a fast connection with a popular torrent, 100 to 200 gives aria2 more sources.

  5. 05

    Do not choke your upload

    If uploading fills your connection, downloads slow down too, because the acknowledgements for incoming data have to queue. Cap max-overall-upload-limit below your upload speed.

aria2.conf — BitTorrent
listen-port=6881
dht-listen-port=6881
enable-dht=true
enable-peer-exchange=true
bt-enable-lpd=true
bt-max-peers=128
max-overall-upload-limit=2M

Forward port 6881 for TCP and UDP. Set max-overall-upload-limit to about 80 % of your upload speed; 2M is only an example. This block was loaded by aria2 1.37.0 with no warnings. We did not benchmark swarms: real torrent speed depends on the peers.

Disk: allocation and cache

Before writing, aria2 reserves space for the file. We downloaded a 2 GiB file with each mode on an SSD with ext4, twice each:

file-allocationOur time (2 GiB)Use it when
falloc3.9–4.2 sext4, btrfs, xfs or NTFS: reserves space almost instantly. The best default.
trunc4.1–4.5 sfalloc is not supported. Sets the size without writing.
prealloc4.1–4.8 sYou need the space truly written in advance. Writes the whole file before downloading, which takes minutes on a hard drive for big files.
none4.6–4.6 sFAT32, exFAT, SD cards and network shares, where reserving space is slow or impossible.

On a fast SSD the mode hardly matters: all four took 3.8 to 4.8 seconds. The difference shows on hard drives and slow media, where prealloc writes the full file first and none causes fragmentation. disk-cache (16M by default) collects writes in memory; 64M helps hard drives with many connections, and does little on an SSD.

Measure your own speed

Change one setting at a time and compare. aria2 prints a status line while it downloads:

aria2c -x 16 -s 16 -k 1M https://example.com/large.iso[#3c0a45 22MiB/47MiB(47%) CN:16 DL:23MiB ETA:1s]

CN is the number of open connections and DL the current speed. If CN stays low, look at min-split-size or the server; if DL is flat at your plan's speed, the line is the limit. For a running aria2, ask over JSON-RPC:

curl -s http://localhost:6800/jsonrpc -d '{"jsonrpc":"2.0","id":1,"method":"aria2.getGlobalStat","params":["token:YOUR_SECRET"]}'

downloadSpeed is in bytes per second. Use a large file from a fast server for tests; a small file finishes before the connections ramp up.

Troubleshooting

Only one or two connections open (CN:1 or CN:2)

Either max-connection-per-server is still 1 (the default), or the file is too small for min-split-size. Set -x 16 -s 16 -k 1M and try again. Some servers also refuse range requests, and then only one connection is possible.

Errors 503, 429 or 403 after raising connections

The server limits connections per client. Lower -x to 4 or 8. In our test, asking for more connections than the server allows made the download slower, not faster.

Torrent stuck at 0 B/s with seeders listed

You cannot reach the peers. Add fresh trackers from the tracker list, set a fixed listen-port and dht-listen-port, and forward that port for TCP and UDP.

The computer freezes or the disk sits at 100 %

Use file-allocation=falloc (or none on FAT32 and exFAT), raise disk-cache to 64M, and lower max-concurrent-downloads.

Speed is capped well below my line

Check max-overall-download-limit and max-download-limit (0 means unlimited), test without --all-proxy, and compare with another server: the bottleneck may be the server you are downloading from.

FAQ

How many connections should I use?

Start with 16, aria2's maximum per server. If the server answers with 503, 429 or 403, go down to 8 or 4. In our measurements extra connections cost almost nothing when the line was the limit, but they did cost time when the server refused them.

Why is 16 the maximum?

aria2 limits max-connection-per-server to 1–16 ("must be between 1 and 16"). To go further, use mirrors: the limit counts per host.

What is the difference between -x and -s?

-x (max-connection-per-server) caps connections to one host; -s (split) is how many pieces one file is cut into. A file uses at most the smaller of the two per host, so set both.

Does the WebUI or a GUI change the speed?

No. WebUIs and GUIs only send settings to aria2. The same options apply whether you set them in aria2.conf, on the command line or in a GUI.

Related resources