Performance testing

Introduction

JMeter is a 100% pure java application for performance testing. It is a testing tool that is used for measuring and analyzing the performance of different products and software services.

JMeter is a tool for testing web applications and is mainly used for testing web services, JDBC database connections, and also TCP connections. It is an open source java based application developed by Stefano Mazzocchi of the Apache software foundation. Using Jmeter we can perform various activities like regression testing, functional testing, load testing, and stress testing. 

Why JMeter?

  • Free of cost: Jmeter is an open source, it has a friendly interface and it allows users to automate their work. 
  • Performance Testing of Applications: JMeter helps in the performance testing of both dynamic and static resources, dynamic resources like JSP and servlets, and static resources such as HTML and Java Scripts. 
  • Load Testing and Stress Testing: Performance testing using Jmeter includes load testing and stress testing so that it can identify the maximum concurrent users that the server can handle. 
  • Graphical Analysis: Using JMeter, enables the performance testing representation in a graphical format like the tree, table, report, and also graph. 
  • Platform Independent: Jmeter is purely on java based and we can use Jmeter across any platform.

Why Performance Testing?

Performance testing is a process of testing a software application under a specific workload. Performance testing is performed to test the speed, resource usage, response time, and reliability. It enables stakeholders to have an idea about the software applications’ stability and scalability. 

Performance Testing Process: 

The performance testing process is as follows:

Performance Testing Process
  1. Requirement Gathering: Identify the requirements and gathered them from clients. 
  2. Selection of Tools: After completing the analysis, select the list of available tools depending on the cost of the tool and the technology used. 
  3. Performance Test Plan: once test designing and planning are done, next is the test plan which decides how the performance test will take place. 
  4. Performance Test Development: Here we identified the use cases of functionality and once the client approves the use cases then we can start development. And parallel the test environment is set up. 
  5. Performance Test Modeling: For test execution, we have created a performance load model, and here we will check the performance whether achieve the performance matrices provided by the client or not. 
  6. Execution of Test: Here we will execute the test code and compare the actual and expected results. 
  7. Test Result Analysis: In performance testing results are the most important deliverable. 
  8. Report: once all the above steps are done, it is necessary to have a simplified report summary. 

Performance Testing Matrices: 

Metrics are used to determine how well performance testing performance under various conditions. 

  1. Processor Usage: It defines the time spent by the processor to execute threads. 
  2. Memory Use: Is used to run and load application 
  3. Disk Time: To write and read a request how much time is taken by the disk. 
  4. Throughput: It is used to calculate the amount of bandwidth needed for tests. As well as the amount of data needed to analyze request passing between the user server and the application main server received the request of rate per second by the network. 
  5. Thread Counts: Determining the application by checking the number of active and running threads. 

How to download and install JMeter: 

Step 1: Install Java

Check if java is installed or not (if not then please run this command in the command prompt- sudo apt-get install openjdk-8-jdk -y

check the java version. If java is installed successfully on your system, then it will show the output as given in the below image. 

Step 2: Download JMeter

Go to the Apache JMeter website to download the JMeter.

Step 3: Installation

once downloaded, unzip the downloaded file with the following command.

In Terminal:- unzip Apache-Jmeter-5.5.zip 

Step 4: Launch JMeter

Change the directory of JMeter 

cd apache-jmeter-5.5/bin 

Now start the JMeter using the following command 

./jmeter 

Performance Testing using Jmeter with Example: 

Create the first Test plan: 

  1. Adding a Thread Group: 

select Test Plan and add thread group->Add->Threads(Performance Testing)->Thread Group 

we must add the following details: 

  • Thread Name: Performance Testing 
  • Number of Threads (Users): Where you can choose the number of users you want
  • Ramp-up period in seconds: The ramp-up period is the amount of time it takes for all the threads to execute. If the thread count is 100 and the ramp-up time is 10 sec. then 100 threads will be executed in 10 seconds. 
  • Loop count: You can choose the test to run a number of times. 

2. Adding HTTP Request: 

Add sample HTTP Request by navigating Add->Sampler->HTTP Request

we must add the following details:

  • HTTP Request name example: Netflix homepage 
  • Protocol: HTTPS 
  • Server name: https://www.netflix.com where we want to perform performance testing 
  • HTTP Request Method: Example GET Method 
  • Path: Path will be the location of resources on the server that you are targeting. 
  • Port Number: if the port is a standard HTTP port of 80, you can leave the port number blank.

HTTP Request as Netflix homepage Now let’s add listeners.

3. Adding Listeners: 

Here we are adding three different listeners. 

  • View Result in Tree
  • View the Result in Table
  • Graph Result

4. Running the Test: 

  • Save this JMeter test 
  • Click the green button and run the test. 

5. View Result Tree: 

This listener has the advantage of being able to check both the request and the answers by comparing the requirement and the actual outcome.

6. View Results in Table: 

In a table format, it shows all samplers data 

Listener shows the below data: 

  • Sample: Number of Samplers in total 
  • Start Time: It is the time when Samples are given out 
  • Thread Name: The Threads Name 
  • Label: Label 
  • Sample Time: Once the request is initiated by the server, the time taken to get the response to the request is the sample time 
  • Status: Status as Pass/Fail 
  • Bytes: The client has received bytes 
  • Sent Bytes: Data is delivered to the server in bytes 
  • Latency: It is the amount of time it takes for a programmer to reply to a users request 
  • Connect Time: This is the amount of time it takes for a request to be delivered to the server 

7. Graph Result: 

The graph result listeners should be used if the user expects results in graph form. 

8. Summary Report: 

The summary report contains all the necessary informational data for analysis. 

The below data is provided by a listener: 

  • Label: Name of URL 
  • Samples: Number of users per request
  • Average: Time taken by samples to run 
  • Min: Minimum time taken by the sample
  • Max: Maximum time taken by the sample 
  • Std Dev: It differs from the average reaction time of the sample
  • Error%: Failed request percent 
  • Throughput: Total number of requests handled by the server 
  • KB/Sec: It is the downloaded data in KB/Sec

Conclusion: 

Apache JMeter is an open-source tool with the required features. It is purely based on java based application of performance testing-now you understood the process of performing performance testing using JMeter and came across different performance matrices. 

Read our blog on Load Testing using JMeter