
The rise of the smartphone and easy connectivity to the internet has made access to information easier with most of them accessing websites and web applications from their smartphones.
As a performance engineer, I would like to run my load test on different network speeds like 1 mbps, 4 mpbs, 16 mbps and so on to ensure the app performance.
Why it is needed?
Day by day, mobile traffic over desktop traffic is growing, there is a need to focus on mobile users for performance testing. hence, it is very important to watch how good we are at mobile else it could be lose to business.
Mobile web traffic comprises users with different connection speeds. So, it is very important to perform load testing on mobile apps with different connection speeds.
So it’s time to Throttle Outgoing Bandwidth to Simulate Different Network Speeds.
By default, Jmeter will send the requests to the target server as fast as it can.
Throttling Outgoing Bandwidth to Simulate Different Network Speeds
JMeter has capability to throttle the outgoing bandwidth in order to have different network speed and to achieve that follow the below mentioned steps:
1. Open jmeter.properties file located in /bin folder of JMeter

2. Search for keyword “cps”

3. If you search using “cps” then you will get two properties:
- httpclient.socket.http.cps=0
- httpclient.socket.https.cps=0
Remove “#” to enable the properties

The first property simulates the speed when you use HTTP method (protocol) and the second property is used to simulate the speed for HTTPS method.
4. Calculate the value using below formula
CPS = RB * 128
where:
CPS = Characters per second
RB = Required Bandwidth that you need to set for the load test. The input value of required bandwidth should be in kbps.

5. Save and close the file. Restart JMeter

- Example if you want to simulate 1000 kbps speed for the test then
cps = 10000 * 128
cps = 128000
Note: You need to use the HTTPClient3.1 or HTTPClient4 implementation to be able to adjust the JMeter bandwidth.HTTP Request Defaults is the fastest and easiest way to implement all HTTP Request samplers
If you want to set a bandwidth while executing in non GUI mode, below command can be useful .
jmeter -Jhttpclient.socket.http.cps=<cps value> -n -t <path of .jmx>
Points to remember:
- Check the testing environment network bandwidth (where the test to be conducted) before simulating the speed. Because JMeter can only simulate the bandwidth equal to or less than the testing environment network bandwidth.
- Use RB (Required Bandwidth) value in kbps for CPS calculation.
- In a distributed mode, you can set a different bandwidth for each remote engine by specifying your desired ‘cps’ value in the user.properties file to run the test cases.
References:
https://blog.e-zest.com/how-to-simulate-network-bandwidth-in-jmeter
https://medium.com/@priyank.it/jmeter-different-network-speeds-41e7f3d4b7ab
Categories: Uncategorized
Hi Small update in the command.
please update you command with “J” just before -httpclient.socket.http.cps=.
like – jmeter -Jhttpclient.socket.http.cps= -n -t
Thanks ,update the same
Hi, The bandwidth settings mentioned here, is it applicable for each thread/thread group? ex: If I give CPS as 21888 and run a test of 100 users, how it works?
It is applicable to whole thread group ( no of ussers) and all users will use this bandwidth.In your case 100 user loaded would be tested for 21888 CPS .
Thanks team for the reply. We have one scenario , need to execute a 100 concurrent user load test and each virtual user internet upload speed is 2 Mbps . so what is the cps value in the file. whether cps value is setting on each virtual user level or for all the virtual user
Option 1 ( 2 Mbps = 256000 cps)
httpclient.socket.http.cps=256000
httpclient.socket.https.cps=256000
Option 2 ( 2 Mbps *100 concurrent user = 25600000 cps)
httpclient.socket.http.cps=25600000
httpclient.socket.https.cps=25600000
Option 1