At Agira, Technology Simplified, Innovation Delivered, and Empowering Business is what we are passionate about. We always strive to build solutions that boost your productivity.

,

How To Perform Load & Stress Testing Using JMeter

  • By Bharanidharan Arumugam
  • June 13, 2018
  • 1829 Views

Recently, one of our client had a opinion of conducting a conference for different level of audience from Medicine arena. At the same time , he also has a big plan to give a demo & depth analysis about their products & equipment’s through his website. To take it forward, Our first & foremost consideration is to check the capacity of the site to hold the N number of users’s. So, we started experimenting it by performing various operations from load & stress test using JMeter and the result is something extraordinary & fortunately all the metrics we used most precisely met our expectations to the core. With a same note, Planning to discuss about this real time scenario with you guys to portrait how we implemented it in our project. I’m pretty much sure that this article could make you informative & resourceful at the end.
Let’s walk through to discuss how to perform the basic load and stress testing using Jmeter in your web application. Plus, we also have a look on how to use the graphical user interface to build a test plan and to run tests against a web server.
JMeter is an open source desktop application that is designed to load the test and to measure the performance. Also, we can use it to simulate various loads scenarios and output performance data in several ways, including CSV and XML files, and graphs.

JMeter Performance Testing includes:

JMeter Performance Test
Its written based on Ubuntu, but it work in other Linux libraries too. For the performance testing, don’t use production server, i.e., prepare one more server (we will call it as uat server) just equivalent production server.

Related: A Guide for Web Automation Testing With Ruby Cucumber And Watir

 

Prerequisites

Java – Apache Jmeter 4.0 requires Java 8 or 9
Apache JMeter is developed in Java, so we need to make sure Java is installed with the help of below command:

$ java -version

 
2. Apache JMeter
Download JMeter and unzip the zip/tar file into the directory where you want JMeter to be installed
3. Launch Jmeter by using below commands

$ cd <jmeter unzip location>
$ ./jmeter.sh

 
 

Process & Overview

The figure below shows how JMeter simulates the heavy load :
JMeter Apache Sampler
Here is the roadmap for this practical example
JMeter Test Plan Flow

Step 1: Add a thread group

a. Launch JMeter using above command
b. Select Test Plan on the JMeter tree
c. Add Thread Group – Right click on the “Test Plan.”
d. Add a new thread group: Add -> Threads (Users) -> Thread Group
jmeter
In thread group control panel, enter thread properties as below:
Jmeter

  • Setting the number of threads: 100 (Number of users connected to target website: 100)
  • Setting the loop count: 10 (Number of time to execute testing)
  • Setting the Ramp-Up Period: 100 (Defines how long it will take JMeter to get all threads running)

The Thread Count and The Loop Counts are different.
Thread Count VS Loop Count
Ramp-Up Period addresses the JMeter whether how long it can delay before starting next user. For instance, Let’s assume we have 100 users, and on other hands, we have 100 second Ramp-Up period, then the delay between starting users would be 1 second (100 users /100 seconds)
User Delay HTTP

Step 2: Add an HTTP request

Next, we need to add HTTP request JMeter elements in this test.
HTTP request Default

  • This element can be added by right-clicking on the Thread Group
  • Selecting: Add ->
  • Selecting Config Element ->
  • Selecting HTTP Request Defaults.

HTTP-request-defaults
In the HTTP Request Defaults control panel, then you can enter the Website name which we are going to do performance testing. For example: http://www.google.com/

HTTP Request

  • Right-click on Thread Group
  • Selecting: Add ->
  • Selecting: Sampler ->
  • Selecting: HTTP Request.

Jmeter
In HTTP Request Control Panel, the Path field indicates which URL request you want to send to Google server.

For example, if you enter “search” in path field. JMeter will create the URL request http://www.google.com/search to that server.
If you keep the Path field blank, JMeter will create the URL request http://www.google.com to that server.

Step 3: Adding Graph result

JMeter can show the test result in Graph format.
Right click Test Plan, Add -> Listener -> Graph Results
Graph-results

Step 4: Run Test and get the test result

Press Run button (Ctrl + R) on Toolbar to start the testing process. You will see the test result display on Graph at the real time. Don’t test using GUI mode!
We recommend to save this test as ‘jmx’ load and run from aws instance so that we will get more accurate results.
The image below presents a graph of a test plan for sample example, where we simulated 10 users who accessed the website with loop count as 10.

There are the following statistics, represented in colors:

 

  • Black: The total number of current samples sent.
  • Blue: The current average of all samples sent.
  • Red: The current standard deviation.
  • Green: Throughput rate that represents the number of requests per minute the server handled

We have to build different test samples with a different plan, i.e., building test plan with different criteria and save those test plan as jmx.
result
Then load those jmx into aws instance and prepare the test results like below. Let analyze the performance of the server in below figure.
Jmeter result
To analyze the performance of the web server under test, we should focus on 2 parameters a) Throughput b) Deviation.
The Throughput is the most significant parameter which represents the ability of the server to handle the heavy load. The higher the Throughput will bring the better server performance.
In this test, the throughput of that server is good. This value is quite decent, so we can conclude that server has good performance.

Related: Reasons Why Manual Testing Is Inevitable ?

The deviation is shown in red – it indicates the deviation from the average. The smaller, the better.
NOTE: The above values depend on several factors like current server load at Google, your internet speed, your CPU power, etc. Hence, it’s very unlikely that you will get the same results as above. So don’t panic!

Advantages

 

  • The JMeter testing tool offers following benefit in Performance Testing.
  • JMeter can be used to test the performance of both static resources such as JavaScript and HTML, as well as dynamic resources.
  • It can help us to find the maximum number of concurrent users that your website can handle.
  • It provides a variety of graphical performance reports for depth analysis.

Besides exploring, our pool of experts never refuse to share their knowledge with us. You could get more blogs about Technologies & Web development from the experts. Get tuned with us. You could also share your valuable ideas & thoughts with us in the comment section.
For more info reach us at info@agiratech.com

Bharanidharan Arumugam

Technical Architect | Tech Lead | Mentor | - An enthusiastic & vibrant Full stack developer has 7 plus years of experience in Web development arena. Owns legitimate knowledge in Ruby, Ruby On Rails, AngularJs, NodeJs, MEAN Stack, CMS Services. Apart all, A Modest human who strictly says "No To Harming Humans".