Simulating Different Network Speeds using JMETER - An essential aspect for mobile app performance test

Simulating Different Network Speeds using JMETER

In the current digital world, mobile app usage has overtaken desktop traffic - and this trend just looks set to rise. But what does this mean for us?

For performance engineers, it means that now, more than ever, we need to focus on mobile users when running performance tests. If our mobile app doesn’t perform well - we stand to lose a lot of business.


How to Load Test Mobile Apps and Sites with Different Connection Speeds


In most of the cases, mobile device users access the internet via their cellular operator network. The mobile network coverage will vary depending on their location, meaning the connection speed will vary. Hence it is very critical to ensure that the system can fully handle mobile and tablets - even when they have different internet connection speeds.

 In this session, I’ll be presenting about how to simulate such scenarios by controlling the bandwidth of simulated virtual users in a JMeter load test.

 By default, Jmeter will send the requests to the target server as fast as it can. This is great for generating the load on the server - 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, mobile users are limited by network bandwidth, which can slow them down even more.


Throttling Outgoing Bandwidth to Simulate Different Network Speeds

  JMeter gives us the option to throttle outgoing bandwidth in order to simulate different network speeds. The bandwidth can be controlled through these two properties:


  1. socket.http.cps=0
  2. socket.https.cps=0



These are for the HTTP and HTTPS protocols respectively. The properties default to zero, which means no limitations. The acronym “cps” stands for “characters per second”. When you set the properties to something above zero, the bandwidth will be throttled in accordance with your setting.



Here’s the formula of calculating “cps”:

cps = (target bandwidth in kbps * 1024) / 8


For example: to emulate the GPRS cellular network speed (which is 171 Kbits/second downstream), the relevant CPS value would be: 21888 (171 * 1024/8)



So here’s how you can limit the bandwidth through these properties:


  1. Add these two lines to the file (you’ll find this in the bin folder of your JMeter installation)





You’ll need to restart Jmeter to pick these properties up



  1. Alternatively, 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



Now let’s see it in action!!!!



1 favorite thumb_down thumb_up 0 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist

Outline/structure of the Session


Need for network bandwidth simulation 

How to achieve it through JMETER

Live Demo

Learning Outcome

Network bandwidth simulation using jmeter will help the testers to effectively test multiple mobile apps under real time network condition

Target Audience

Test Lead, Test Manager, Performance Engineers , Automation Engineers

schedule Submitted 2 years ago

Comments Subscribe to Comments

comment Comment on this Submission