Performance and Load Testing with JMeter for beginners

Software testing is required to ensure that the application runs without any failures and software testing is a necessity unless and until there is software development. Before starting off, let’s firstly discuss what is load testing and performance testing.

Performance Testing:

  • Browser, page, and network response times
  • Server request processing times
  • Acceptable concurrent user volumes
  • Processor memory consumption; number and type of errors that might be encountered with app

Load Testing:

What is Jmeter?

Working of Jmeter

JMeter simulates a group of users sending requests to a target server, and return statistics information of the target server that describes the performance of the target server via tables, graphs, etc.

Jmeter Elements

  • Thread Groups
  • Samplers
  • Listeners

Thread Groups:

Steps to add a thread group:

Add>>Threads>> Thread Group

In simple words, Thread Groups is a collection of threads. Each thread indicates the total number of users performing the script execution. It is the base element for every JMeter test plan. The thread group allows you to set the number of threads for each group. If the number of threads is set to 100, JMeter will create and simulate 100 user requests to the server under test.

Elements of Thread Groups

Ramp-up Time: Ramp-up time is the time it takes to execute all threads. For eg: If we have 20 threads load, and the ramp-up period is given as 20 seconds, then JMeter will take 20 seconds to get all 20 threads up and running i.e. 1 second per thread.

Loop Count: Loop count tells JMeter how many times to repeat your test. If you enter a loop count as 1, then JMeter will run the test only once. If we want our test plan to run repeatedly, we must select the infinite checkbox which runs for infinite times.

Here, the total number of thread i.e user is given as 10 which means JMeter will create and simulate 10 user requests to the server under test. The ramp-up period is 10 which indicates that JMeter will take 10 seconds to get all 10 threads up and running i.e. 1 second per thread and the loop count is 1 which means Jmeter will run the test only once.

Samplers

Steps to add a sampler:

Thread group>>Add>> Sampler

Some of commonly used samplers provided by Apache Jmeter are:

  • HTTP Request: HTTP Request sampler is mostly used sampler for testing web applications. It is used to send HTTP/HTTPS requests to the target web server.

The server name or IP indicates the link of the website under test (eg:www.etsy.com). The Path field indicates which URL request you want to send to Etsy server. For example, if you enter “vintage” in path field. JMeter will create the URL request https://www.etsy.com/vintage to Etsy server.

FTP Request: FTP stands for File Transfer Protocol, it lets the user transfer files to the server, that is download or upload file requests to the server.

JDBC Request: JBBC Request sampler is used to test databases. It lets the user send JDBC Requests consisting of SQL queries to the server database. We must set up a JDBC connection in order to use this sampler.

SMTP Sampler: SMTP Sampler is used to test a mail server. It is used to send email messages using the SMTP protocol.

Listeners

These are some of the data that are provided by listeners:

  • #Samples: Total number of Samples.
  • Average: Average Time.
  • Min: Minimum time a sampler has taken to go to the server.
  • Max: Maximum time request taken to go to the server.
  • Status: Represents as test Pass/Fail symbol.
  • Error%: Number of error sampler/Total number of Sampler.
  • Throughput: Sample received by the server per second.
  • Received KB/second: Defines how many kilobytes per second received by the Client.
  • Sent KB/second: Kilobytes per second are sent to the server.
  • Latency: Delayrecieved in response by the application for the request sent by the user.
  • Std Dev: Deviation from the average value of sample response time.
  • 90% Line: Represents that 10% of the samplers have exceeded time to reach the server.
  • 95% Line: Represents that 5% of the samplers have exceeded time to reach the server.
  • 99% Line: Represents that 1% of the samplers have exceeded time to reach the server.

View results in Tree

View Results in Table

Graph Results

Summary Report

Aggregate Report

Generating JMeter Load Test Dashboard Report

Syntax for executing in non-GUI mode

jmeter -n -t(path of .jmx file) -l(path of jmeter.jmx file) -e(generate HTML reports) -o(path of output folder where you want to save your html file)

  • Jmeter -n: Run jmeter script in non GUI mode.
  • Jmeter -t: pick JMeter.JMX file and will execute it. Path of JMX file is taken which is saved under bin folder.
  • Jmeter -l: path where we want our executed results to be saved into.csv format.
  • Jmeter -e: convert .csv file into HTML format.
  • Jmeter -o: saves the HTML results into a given path along with the HTML file name.

Report Overview

  • Requests Summary shows the percentage of success and failure percent of the test.
  • Statistical table represents the summary of all metrics per transaction.
  • Error table provides the summary of all errors.
  • Response times Over Time is a graphical representation of average response time over time.
  • Response Time Percentiles Over Time (successful responses) is a graphical representation of Min/Max and 3 percentiles response time over time.
  • Active Threads Over Time represents the number of active threads over time.
  • Bytes throughput Over Time represents the throughput of received and sent data over time.
  • Latencies Over Time represents the average latency time over time.
  • Connect Time Over Time represents the connection time over time.
  • Hits per second represent the rate of finished requests over time.
  • Response Time vs Request per second represents the median and average response time depending on the number of current requests.
  • Latency vs Request per second represents the median and average latency time depending on the number of current requests.
  • Response time Overview
  • Times vs Threads represents the average response time depending on the number of currently active threads.
  • Response Time Distribution represents the distribution of the samples depending on their elapsed time and name.

To know more about how to get started with software testing check out Software Testing Fundamentals.

References: