From accessing production readiness, finding the source of performance problems to discovering which application parts are performing poorly, performance testing is the answer to all of your questions. Key performance testing types that help you maintain superior quality are load testing, stress testing, volume/capacity testing, endurance testing, and scalable testing.
Moving ahead, choosing the best tool to conduct performance testing is a big concern. JMeter is an open-source tool provided by Apache that can be used for performance testing of different kinds of client-server applications like websites, web services, databases, FTP servers, etc.
Whether it is cost, customization, community support, record and playback feature, platform independency or versatility to test performance testing type, Jmeter is here to the rescue. This blog will get down to the nitty-gritty to explain why and how Jmeter can be your best bet for performance testing.
Performance testing determines whether the application meets speed, scalability, and stability requirements under expected workloads. Some common performance bottlenecks are
Let’s take a deep dive into JMeter.
JMeter is the most popular open-source load testing tool. The following are the steps mentioned to start the JMeter.
Steps to start Jmeter
Following directories you will find in a Jmeter Directory:
JMeter Test Plan: A test plan describes a series of steps JMeter will execute when run. A complete test plan will consist of one or more Thread Groups, Logic Controllers, Sample Generating Controllers, Listeners, Timers, Assertions, and Configuration Elements.
Run Jmeter thread groups consecutively
If you have multiple Thread Groups and run them they will be executed in parallel. In some scenarios, it causes some problems(i.e dependency between thread groups). In that case, you need to run your thread groups consecutively.
Threads mean no. of Virtual Users in a JMeter.
For example, if you set the number of threads as 100; JMeter will create and simulate 100 user requests to the server under test
How to add ThreadGroup: Right Click on Test Plan-> Hover over Threads(Users)-> Click Thread Group
Let’s explore the Thread Group options
Samplers in JMeter allows JMeter to send different types of requests to a server.
How to add Samplers: Right Click on Thread Group -> Hover over Add -> Hover Over Sampler -> Click on the required Sampler
Name: Any logical name in order to distinguish your request.
Protocol: It mentions the protocol used for example HTTP or HTTPS.
Server Name: This is the domain name of the server
Method: Any of the methods such as GET, PUT, POST, DELETE, etc may be selected from the drop-down
Path: This is the path of the resource. For example “/wiki/Cheese”.
Parameters: Any parameters that are required to be passed will be added in this section.
Body Data: This comes into picture if any JSON, XML, etc needs to be passed in the request. That is added to Body Data.
HTTP Request Defaults
If you are going to send multiple requests to the same web server, consider using an HTTP Request Defaults Configuration Element so you do not have to enter the same information for each HTTP Request.
How to add : Right Click on either of Test Plan/Thread Group/Logic Controller -> Hover over Add -> Hover Over Config Element -> Click on the HTTP Request Defaults
Logic Controllers will decide “When & How” to send a request to a web server.
How to add: Right Click on Thread Group -> Hover over Add -> Hover Over Logic Controllers -> Click on the required Logic Controllers
Random Controller makes all the user requests run in the random order in each loop period.
For example, you have 3 user requests to website http://www.google.com in the following order:
Pre-Processors executes some action just prior to a sample being run.The Pre Processor elements are used to modify the sampler requests before their processing(hence the name pre-processor).
How to add PreProcessor: Right Click on either of Test Plan/Thread Group -> Hover over Add -> Hover Over Add element-> Click on the PreProcessors
Example: User Parameters
User Parameters are used to define values for the variables before they are used in the Samplers. When JMeter executes this Pre-Processor element, it stores the values in the variables which can be referenced by any Samplers within the same thread group.
It will be executed when a Sampler Request finishes its execution. If you need to use a post-processor for a particular Sampler, then add it as a child of that Sampler
How to add Post-Processor: Right Click on either of Test Plan/Thread Group -> Hover over Add -> Hover Over Add element-> Click on the
Example: Regular Expression Extractor
It allows the user to extract values from a server response using a Perl-type regular expression.
An assertion in JMeter is used to validate the response of the request that you have sent to the server.
How to add Assertions: Right Click on either of Test Plan/Thread Group -> Hover over Add -> Hover Over Add element-> Click on theAssertion Assertions
Example: Duration Assertion: The Duration Assertion tests that each server response was received within a given amount of time. Any response that takes longer than the given number of milliseconds (specified by the user) is marked as a failed response.
Timers allow JMeter to delay between each request which a thread makes. A timer can solve the server overload problem.
How to add Timer: Right Click on Thread Group -> Hover over Add -> Hover Over Timer -> Click on the required Timer
Example: Constant Timer
Constant timer delays each user request for the same amount of time. If there are no timers, Jmeter will send the next request in fractions of seconds.
Configuration Element enables us to declare variables, so Samplers can use data through these variables.
How to add a Config element: Right Click on either of Test Plan/Thread Group/Logic Controller -> Hover over Add -> Hover Over Config Element -> Click on the required Config Element
The counter config element is used to create a variable that gets incremented by specified value in each iteration within a range of minimum and maximum values.
2. CSV Data Set Config
CSV Data Set Config element is used to read data from a text or CSV format file. For Example, If you need to perform a load test of a login scenario with 100 unique users. Prepare the data in CSV file with 100 user records with username and password, and you can use this file data in every thread through variables in your requests/samplers by using this configuration element.
Let’s take a look at how the CSV Data Set is configured:
Shows the results of the test execution. They can show results in a different format such as a tree, table, graph or log file
Listeners can be added anywhere in the test, including directly under the test plan. They will collect data only from elements at or below their level.
For example, if we add a Listener to a Thread Group, they only collect information specific to that Thread Group. If you have 3 Thread Groups and a listener attached to each one, those three listeners will show three different sets of data.
How to add a Listener: Right Click on Test plan -> Hover over Add -> Hover Over Listener -> Click on the required Listener
HTTP(S) Test Script Recorder can be used to record all the requests which your web application is making to the server.
Below is the process of using this recorder:
Reducing resource requirements
Some suggestions on reducing resource usage.
Jmeter Test Plan Result
How to resolve HTTP 400 Bad Request error?
Solution: Check payload, URL, headers, port number and path.
How to resolve HTTP 500 internal server error?
Solution: Execute the same request manually using browser also verify which URL out of the 10 under test is creating a bottleneck
This contact form is available only for logged in users.