Jmeter | Different Network Speeds
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. In the case of mobile, user access the internet mainly through their cellular operator network. Moreover, the connection speed might vary depending upon their exact location. It is therefore required to ensure application functionalities on mobile and tablets with varying internet speed.
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. — but not very realistic as real users don’t hit the server non-stop, they will have some time to think between operations. On top of that, each user will have different internet speed available.
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:
By default these values are set to zero means no limitation.If we set something above 0 then the connection speed is throttled. Here the “cps” stands for “characters per second”.
let’s understand “CPS” (characters per second)
CPS = (target bandwidth in kbps * 1024) / 8
So calculate the CPS values as per need and Now update user.properties file with httpclient.socket.http.cps, httpclient.socket.https.cps
- httpclient.socket.http.cps = 21888
- httpclient.socket.https.cps = 21888
- Restart the jmeter for changes to take place
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
Have we done? So what if I need to run test with multiple network speeds like, 2G, 3G, 4G, LTE etc. Do I need to change the “user.properties” file each time? :(
Don’t we have some more cleaner way? Yes we have. :) you can pass the properties’ values via the -J command line argument, like this:
jmeter -Jhttpclient.socket.http.cps=21888 -Jhttpclient.socket.https.cps=21888 -t /path/to/your/testplan.jmx