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:
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
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.