Dmitri Tikhanski is a Contributing Writer to the BlazeMeter blog.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Feb 09 2016

How to Simulate Different Network Speeds in Your JMeter Load Test


Mobile has finally overtaken desktop traffic - and this trend just looks set to rise. But what does this mean for us?

For starters, it means that now, more than ever, we need to focus on mobile users when running performance tests. If our mobile site or application 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 cases, mobile device users access the internet via their cellular operator network. The coverage will vary depending on their location, meaning the connection speed will vary. It is vital to ensure that your website or application can fully handle mobile and tablets - even when they have different internet connection speeds.



In today’s article, I’ll show you how to do this by controlling the bandwidth of simulated virtual users in a JMeter load test.



By default, JMeter will send the requests defined by its Samplers as fast as it can. This is great for producing the load - but not very realistic as real users don’t hammer the server non-stop, they need 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 does give you the option to throttle outgoing bandwidth in order to simulate different network speeds. The bandwidth can be controlled through these two properties:



  1. httpclient.socket.http.cps=0

  2. httpclient.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



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



Note: if you’re not familiar with JMeter Properties, it’s really worth reading the Apache JMeter Properties Customization Guide for more information.



Now let’s see it in action! I created a very simple test plan, consisting of a:




  1. Thread Group with 100 virtual users and 100 iterations

  2. HTTP Request which sends the GET method to a static HTML page

  3. Aggregate Report listener to allow us to see throughput





As you can see from the above image:


  1. The upper-right JMeter instance works at full LAN speed and throughput is ~1,000 requests per second

  2. The bottom-left JMeter instance has a bandwidth limitation in place, which means that throughput doesn’t go above 180 requests per second


Here are some popular bandwidth presets:

Bandwidth                                cps Value                          
GPRS 21888
3G 2688000
4G 19200000
WIFI 802.11a/g 6912000
ADSL 1024000
100 Mb LAN 12800000
Gigabit Lan 128000000


Best Practices


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

  2. If you run your test in the distributed mode you can set a different bandwidth for each remote engine by specifying your desired “cps” value in the file

  3. users can either use the above approach (it’s enough to upload your version of the file along with the test script) or just use the “Network Emulation” settings to set download limit and emulated latency value


I hope that you found this useful! Please share your questions or comments below.


Want to Learn More About JMeter & Load Testing?


If you are new to JMeter, and you’d like to learn more, please sign up for our free online JMeter training course.


For more experienced JMeter users, you'll want to view the on-demand webcast, How to Create Advanced Load Testing Scenarios with JMeter.


arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!