When running large multi-gigabyte file downloads via wget or curl, synchronizing remote cloud repositories with rsync, or streaming database backups in Ubuntu, unconstrained processes can easily saturate your network interface. This bandwidth exhaustion causes severe latency spikes, degrades SSH responsiveness, and interferes with VoIP calls or web traffic for other users sharing the connection.
While low-level traffic control utilities like tc require complex firewall routing tables and administrative root privileges, Trickle is a lightweight, userspace bandwidth shaper. Trickle operates by intercepting standard dynamic socket calls, allowing you to throttle download and upload speeds for any specific application without altering system-wide networking.
Step 1: Install Trickle in Ubuntu
Trickle is readily available in Ubuntu’s official Universe package repository:
- Open your terminal.
- Update your package index and install Trickle:
sudo apt update && sudo apt install -y trickle
Step 2: Limit Bandwidth for an Individual Command
Trickle uses straightforward flags to specify limits in kilobytes per second (KB/s):
-d <rate>: Sets the maximum download speed in KB/s.-u <rate>: Sets the maximum upload speed in KB/s.
For example, to limit a file download via wget to a maximum download ceiling of 300 KB/s:
trickle -d 300 wget https://example.com/large-archive.tar.gz
To throttle both upload and download speeds during an rsync remote backup (e.g., limiting downloads to 500 KB/s and uploads to 100 KB/s):
trickle -d 500 -u 100 rsync -avz /local/backup user@remote:/remote/backup/
Step 3: Run Trickle in Managed Daemon Mode (trickled)
If you need to limit aggregate network usage across multiple applications simultaneously rather than isolated commands, launch the Trickle coordination daemon (trickled):
- Start the daemon with global bandwidth limits (e.g. 1000 KB/s download, 200 KB/s upload):
trickled -d 1000 -u 200
- Now, any process launched simply with the
trickleprefix will automatically coordinate with the daemon and share that shared bandwidth pool dynamically:
trickle sftp [email protected]
Important Trickle Compatibility Note
Because Trickle works via preloading a dynamic linking wrapper (LD_PRELOAD), it operates flawlessly with standard dynamically linked utilities (such as wget, curl, ssh, rsync, and git). However, statically compiled binaries (such as some Go-based CLI utilities) or applications that bypass glibc socket calls cannot be intercepted by Trickle.