Introduction to Performance Testing with JMeter

Areesha Altaf
4 min readJan 6, 2023

For any user of the internet, it is a mental headache to come across website crashes or delays. It can be frustrating and often results in losses for online businesses. In a nutshell, performance issues can be very disappointing. Therefore, it is often wise for teams to invest in performance testing.

A non-functional testing type, performance testing helps analyze the behavior of an application in numerous situations. An application may work flawlessly with a few users per day, but might run into performance issues when encountered with a large concurrent number of users, which results in load or stress on the system. There are various different types of performance testing, each catering to a different performance-related scenario. Performance testing ensures that the speed, response time, stability, and reliability of the application are as required. It also builds confidence that the application in question is up to the mark and results in better execution and less maintenance.

There are many tools available online which can help test the system in the mentioned situations. One of the most commonly used tools is Apache JMeter, a GUI and Java-based open-source software, that helps the user carry out multiple performance testing types like load, stress, spike, etc.

It is quite easy to set up JMeter. A prerequisite is to have JAVA installed and set up as the environment variable already. The next step is to simply download the zip file and execute the bat/sh file. If using Mac, it is even simpler to install with brew using the command “brew install jmeter” and launch using “open /usr/local/bin/jmeter” via terminal.

There are some terms one should be familiar with before using JMeter. Familiarity with these will help a beginner understand performance testing terminologies.

Test Plan

This refers to the main container which contains all the network requests, extractors, headers, assertions, validations, etc. Everything that needs or is needed for performance testing should be inside it.

Threads: Thread Group

This is a set of network requests, or threads, that constitute a flow. For example, requests for login, search item, add to cart, and place order makes up one flow and hence would be part of one thread group. It’s also where properties for the flow are defined, such as number of users, ramp up period, loop count etc.

Sampler: HTTP Request

A common example for this category would be a HTTP request. Your request is defined here, which may contain the endpoint, protocol request method, body, parameters etc.

Config Element: HTTP Header Manager

Most of the time, a set of network requests belonging to the same flow would share a similar set of headers. The Header Manager is one place where all of these can be added, in order to avoid having to add them each time for each request.

Config Element: HTTP Request Defaults

Similar to the Header Manager, you can keep common parameters in the Request Defaults, such as protocol, server name or IP, and shared parameters if any.

Config Element: User-Defined Variables

As the name suggests, any values that you wish to define yourself can be stored here, for example, a random string or random number.

Post Processors: JSON Extractor

The purpose of JSON Extractor is to extract anything from the response data. For example, you may need the authentication token from a login API to pass on to another API. You can use the JSON Extractor to extract it. This will need to be placed within the network request whose data needs to be extracted.

Post Processors: BeanShell PostProcessor

Just like a JSON Extractor can be used to extract JSON data from the response, a PostProcessor can be used to set the value of the extracted JSON path into a named property. We use this further on to pass to the next API to send data outside the thread group.

Logic Controllers

Logic Controllers are used to set conditions in your test plan. For example, IF controllers can be used for If-Else conditions, Loop controllers can be used for redundant processes, etc.

Counters

In order to use loops in logic controllers, you need counters to increment the minimum value up to the maximum, for the number of total repetitions required in the thread group. To repeat a network request a certain number of times, you need to add that request and the counter within the loop controller.

Assertions

Assertions basically verify that the actual outcome meets the desired expectations. There are multiple assertion types, for example, Response or JSON Assertion.

Listeners

The main purpose of listers is to observe and record the results. At the end of the performance testing, you may view the results in the form of various listeners: Results Tree, Results Table, Summary Report, Graph, etc.

Once you have added these, you will have a structure similar to the following. This is a basic framework to get started with simple performance testing. You can use this as a basis to add more as your requirements grow.

--

--