We are hosting an application on remote server. We need to test it with a limited network bandwidth (for users with bad Internet access).
Can I limit my internet bandwidth? For instance: 128 KB per second.
This question focuses on system-wide or container-wide solutions on Linux. See Limiting a specific shell’s internet bandwidth usage for process- or session-specific solutions.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can throttle the network bandwidth on the interface using the command called tc Man page available at http://man7.org/linux/man-pages/man8/tc.8.html
For a simple script, try wondershaper.
An example from using tc:
tc qdisc add dev eth0 root tbf rate 1024kbit latency 50ms burst 1540
Method 2
As noted in previous answer, wondershaper does the job easily.
I include the information from above link by Jwalanta Shrestha
apt-get install wondershaper
wondershaper – An easy tool to limit bandwidth of a particular interface.
$ sudo wondershaper {interface} {down} {up}
the {down} and {up} are bandwidth in kpbs
So for example if you want to limit the bandwidth of interface eth1 to 256kbps downlink and 128kbps uplink,
$ sudo wondershaper eth1 256 128
To clear the limit,
$ sudo wondershaper clear eth1
Method 3
Limiting network resources based on some criterias is the subject of QoS. There are several different ways to control user traffic on Linux systems.
There is a good How-to about advanced routing techniques and traffic control on Linux by Bert Hubert.
Method 4
If you already have an Apache setup somewhere, you can use mod_bw, which also works on proxied connections (i.e. Apache just forwards everything to the proper server, but slows the responses down.)
Method 5
You can also use iptables hashlimit module.
Here is a simple example:
iptables -A FORWARD -m hashlimit –hashlimit-above 512kb/sec
–hashlimit-burst 1mb –hashlimit-mode srcip,dstip –hashlimit-name bwlimit -j DROP
That rule limits traffic that pass through FORWARD chain as 512kb/sec with 1mb burst for each source and destination pair.
Check hashlimit section of iptables manual for more information.
http://ipset.netfilter.org/iptables-extensions.man.html
Method 6
Dummynet does what you want and more, you can even control the latency, random packet loss and lots more.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0