How do you limit max peers per torrent in aria2?
Limiting the maximum number of connected peers per torrent in aria2
is a straightforward process achieved by using the
--bt-max-peers configuration option. This setting allows
users to manage their network bandwidth and system resources effectively
by capping the swarm size for individual torrent downloads. This article
will guide you through applying this limit via the command line,
configuration files, and remote interfaces.
Using the Command Line Option
When starting a download directly from the terminal, you can append
the --bt-max-peers flag followed by your desired numeric
limit. By default, aria2 sets this value to 55. If you want to restrict
a specific download to a maximum of 30 peers, you would execute the
command like this:
aria2c --bt-max-peers=30 "magnet:?xt=urn:btih:..."
This restriction applies individually to each torrent session initiated with this command, ensuring that the client does not over-allocate connections to a single swarm.
Making the Limit Permanent via Configuration File
If you prefer to apply this limit globally to all future torrent
downloads without typing the flag every time, you can add it to your
aria2 configuration file (typically named aria2.conf).
- Open your
aria2.conffile in a text editor. - Add the following line to the file:
bt-max-peers=30 - Save and close the file.
When aria2 launches, it automatically reads this file and enforces the 30-peer maximum cap on every torrent you download.
Adjusting Peers Dynamically via RPC
For users running aria2 as a background daemon and managing it through WebUIs (like AriaNg) or custom scripts, the peer limit can be adjusted dynamically using the XML-RPC or JSON-RPC interfaces.
You can change this setting globally on the fly by calling the
aria2.changeGlobalOption method, or alter it for an active,
specific download using aria2.changeOption. The key-value
pair to pass in your JSON payload is:
"bt-max-peers": "30"
This flexibility allows you to optimize your torrenting connectivity based on real-time network conditions without needing to restart the application.