Limiting bandwidth for cURL transfers avoids saturating shared links, simulates slower connections, and enforces per-job rate caps. Constrained transfers support realistic performance tests and reduce the risk of overwhelming remote services during bulk downloads or scripted workloads.
The --limit-rate option throttles the average transfer speed across the lifetime of a request. Values are specified in bytes per second, optionally with suffixes such as k, m, or g, and the limiter applies to both download and upload directions for the active transfer handled by the current cURL process.
Rate limiting in cURL remains purely client side and does not replace server-side quotas, traffic shaping, or quality-of-service rules. Very small limits can trigger server timeouts or job overruns, while very large limits behave similarly to unconstrained transfers, so choosing realistic values and confirming effective throughput is essential.
Steps to limit bandwidth rate in cURL:
- Check the installed cURL version and supported protocols.
$ curl --version curl 8.5.0 (x86_64-pc-linux-gnu) libcurl/8.5.0 OpenSSL/3.0.11 zlib/1.2.13 brotli/1.0.9 libidn2/2.3.4 Release-Date: 2023-12-06 Protocols: dict file ftp ftps gopher gophers http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM SSL TLS-SRP
Any reasonably recent cURL build supports --limit-rate for HTTP, FTP, and other common protocols.
- Download a file with a simple bandwidth cap using --limit-rate.
$ curl --limit-rate 100k "https://www.example.com/largefile.iso" --output largefile.iso % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 12 50.0M 12 6144k 0 0 102k 0 0:08:22 0:01:01 0:07:21 101k ##### snipped #####100k limits the average download rate to roughly 100 KB/s using bytes per second rather than bits per second.
- Apply the same limiter to an upload using --upload-file and optional credentials.
$ curl --limit-rate 50k --upload-file "./report.tar.gz" "ftp://ftp.example.com/incoming/" --user user:pass % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 20 10.0M 0 0 20 2048k 50k 0 0:03:25 0:00:41 0:02:44 51k ##### snipped #####The limiter applies to the active transfer direction so uploads and downloads obey the same --limit-rate value.
- Try different limits and suffixes to model a range of connection speeds.
$ curl --limit-rate 256k "https://www.example.com/video.mp4" --output video.mp4 $ curl --limit-rate 1m "https://www.example.com/archive.zip" --output archive.zip $ curl --limit-rate 2g "https://www.example.com/dataset.bin" --output dataset.bin
Suffixes k, m, and g represent kibibytes, mebibytes, and gibibytes per second based on bytes, not bits.
- Verify the effective download rate using transfer statistics from --write-out.
$ curl --limit-rate 200k --output /dev/null --write-out "\n%{speed_download}\n" "https://www.example.com/file.bin" ##### snipped progress meter ##### 204789.000000Success signals: the reported speed_download value stays close to the configured limit and real transfers feel consistently throttled.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
