About Me / Projects / CustomGPTs / Blog / Apps / Games

Stress Testing With JMeter: An Overview and Example Using Lebiru.FileService šŸ“ˆ

Author's Profile Picture

Bilal A.

It’s the night before the big debut of your online store. The clock is ticking, and every minute brings you closer to the site going live. Suddenly, the site launches, and pre-orders start flooding in! You rejoice and celebrate, until you encounter the dreaded error message: 500 Internal Server Error. Your fans can’t process orders, and the app is buckling under the spike in users. Could this disaster have been prevented?

Stress Testing is the key to ensuring your application can handle waves of requests and operations during an extended period of time. In this blog post, we will dive into what stress testing is, provide an overview of JMeter, and run a stress test against my app, Lebiru.FileService. Let’s dive in!

Developer standing in front of their app and testing servers showing good performance metrics.

Ensure quality performance using stress tests!

What is Stress Testing?

Stress testing is a type of performance testing that evaluates how an application behaves under extreme workloads, such as heavy user traffic or resource utilization. It ensures the application maintains stability, functionality, and performance when pushed beyond its limits. Stress testing can reveal bottlenecks, memory leaks, and other critical issues that could hinder the app’s performance in production.

There are various types of stress tests, each designed for specific scenarios:

Why is Stress Testing Important?

Stress testing plays a critical role in software development by ensuring that applications can handle real-world scenarios. It helps identify vulnerabilities that might otherwise go unnoticed in standard testing environments. With stress testing, developers can:

Stress tests typically involve software developers, QA engineers, and system administrators. They are conducted in staging or pre-production environments that closely replicate the production setup to provide accurate results.

JMeter: The Defacto Stress Testing Open Source Tool

Apache JMeter, currently at version 5.6.3, is a powerful open-source tool for stress testing. It simulates heavy user traffic and measures the performance of web applications under load. JMeter is widely used for its flexibility and ability to test various protocols such as HTTP, FTP, and JDBC.

Apache JMeter Logo

Apache JMeter

How to Download and Install JMeter on Windows

  1. Download JMeter

    1. Visit the official JMeter website: Apache JMeter Download Page.

    2. Under the Binaries section, click the link for the latest .zip file to download the JMeter package.

  2. Install JMeter

    1. Extract the downloaded .zip file:

      • Right-click the file and select Extract All.
      • Choose a folder (e.g., C:\apache-jmeter) to extract the files.
    2. Navigate to the extracted JMeter directory (e.g., C:\apache-jmeter-x.x).

  3. Set Up Java (Prerequisite)

    1. Check if Java is installed:

      java -version

      If Java is not installed, download and install the latest Java Development Kit (JDK).

    2. Set the JAVA_HOME environment variable:

      • Open the Start Menu, search for Environment Variables, and select Edit the system environment variables.
      • In the System Properties window, click Environment Variables.
      • Under System variables, click New and set:
        • Variable Name: JAVA_HOME
        • Variable Value: Path to your Java installation (e.g., C:\Program Files\Java\jdk-x.x.x).
      • Click OK to save.
  4. Run JMeter

    1. Navigate to the JMeter bin directory (e.g., C:\apache-jmeter-x.x\bin).

    2. Double-click the jmeter.bat file to start JMeter.

    3. Optional: Run JMeter via Command Line:

      jmeter.bat
  5. Verify the Installation

    Once JMeter starts, you should see the JMeter GUI. From here, you can begin creating and running your tests.

An image of what JMeter GUI looks like after a successful installation

This is the opening GUI when running JMeter

JMeter Components Overview

JMeter components are the building blocks of a performance test plan, each serving a specific purpose in defining and executing tests. From configuring user behavior to collecting and analyzing test results, these components work together to simulate real-world scenarios and measure application performance effectively.

Configuring a JMeter test is straightforward using its UI. Navigate to File > New to create a new test plan, then add components via Right-click > Add > Threads (Users) > Thread Group, and so on. Each component’s settings can be adjusted via the properties panel.

An image of the 5 JMeter Components

JMeter Components: Test Plan, Thread Group, HTTP Request, Results Tree, Summary Report

Let’s explore five key JMeter components and their roles in creating robust test plans.

Test Plan

A JMeter test plan outlines the testing workflow, defining the actions to be performed during the test. It serves as the blueprint for all test configurations and components.

Thread Group

The thread group defines the number of virtual users (threads) and the test’s duration. By configuring the thread count, ramp-up period, and loop count, you can simulate different user loads.

HTTP Request

The HTTP request sampler specifies the requests to be sent to the server. You can configure parameters such as the endpoint URL, request method (GET, POST, etc.), and payload.

View Results Tree Listener

The View Results Tree Listener provides a detailed log of each request and response during the test. It’s useful for debugging and analyzing specific transactions.

Summary Report Listener

The Summary Report Listener provides an aggregated view of test results, including metrics like response time, throughput, and error rate.

JMeter test plans are saved as .jmx files, allowing them to be version controlled and edited as plain text. This makes it easy to collaborate and automate testing workflows.

JMeter Stress Test Sample #1: Lebiru.FileService Homepage

Pre-requisite: Ensure Java is installed on your machine. Download Java here.

Pre-requisite: Ensure Docker is installed on your machine. Download Docker here.

Pro-tip: Clone the repo from GitHub to easily follow along. Clone repo here.

Test Goal #1

The goal of this exercise is to assess how well Lebiru.FileService app’s homepage endpoint handles volume. By running the docker image of Lebiru.FileService and navigating to the URL http://localhost:3000/File/Home on your computer, you will be greeted with the homepage for Lebiru.FileService.

An image of Lebiru.FileService Homepage

Lebiru.FileService Homepage

  1. Navigate to jmeter-stress-example repository and run the following bash command:
    bash run-lebiru-fileservice.sh
    This runs Lebiru.FileService on your server by pulling the latest docker image and runs the container using Docker. You should be able to navigate to http://localhost:3000/File/Home and see the homepage.
  2. Open the file Test Plan #1 - Lebiru.FileService HomePage.jmx using JMeter to see the populated JMeter Components on the left side.
  3. Now click the big green button near the center of the button toolbar on the top to run the JMeter test.

As the JMeter test executes, you will able to see live metrics being updated in "Results Tree" and "Summary Report". After 5 minutes the test should end and give the overall metrics of the test in the "Summary Report" view.

An image of the first Test Scenario results

Summary Report of Test Scenario #1

Test Goal #2

The goal of this exercise is to evaluate how well the Lebiru.FileService file upload endpoint manages under concurrent user file upload.

We will upload a chibified version of my cat, Filfil, to Lebiru.FileService. Want to chibi-fy your own photos? Use my AI agent Chibify-Me!

  1. Navigate to jmeter-stress-example repository and run the following bash command:
    bash run-lebiru-fileservice.sh
    This runs Lebiru.FileService on your server by pulling the latest docker image and runs the container using Docker. You should be able to navigate to http://localhost:3000/File/Home and see the homepage.
  2. Open the file Test Plan #2 - Lebiru.FileService CreateDoc.jmx using JMeter to see the populated JMeter Components on the left side.
  3. Ensure the component "HTTP Request" is referencing the image in the repo filfil-by-chibify-me.png
  4. Now click the big green button near the center of the button toolbar on the top to run the JMeter test.

As the JMeter test executes, you will able to see live metrics being updated in "Results Tree" and "Summary Report". Try also navigating to the homepage and see the dashboard update with multiple file images of Filfil. Isn't that cool? After 1 minute the test should end and give the overall metrics of the test in the "Summary Report" view.

An image of the second Test Scenario results

Summary Report of Test Scenario #2

Stress Testing Results

Below are the metrics my server was able to reach when running the two test scenarios. Seeing this gives us a confidence boost knowning that Lebiru.FileService is able to handle stress volumes!

Run Details
HomePage Test # Samples: 809,660
Average (ms): 1
Min (ms): 0
Max (ms): 29
Std. Dev (ms): 0.89
Error %: 0.00%
Throughput (requests/sec): 2,699.4
Received KB/sec: 41,366.16
Sent KB/sec: 337.42
Avg. Bytes: 15,692.0
CreateDoc Test # Samples: 14,008
Average (ms): 10
Min (ms): 4
Max (ms): 144
Std. Dev (ms): 5.55
Error %: 0.00%
Throughput (requests/sec): 269.6
Received KB/sec: 47.39
Sent KB/sec: 109,697.88
Avg. Bytes: 180.0

Let’s Wrap It Up

Stress testing is an essential practice for ensuring your application’s reliability under heavy load. Using JMeter, we successfully tested the Lebiru.FileService app’s homepage and file upload endpoints, confirming their stability under defined conditions.

Have you tried stress testing before? Share your experiences and favorite tools in the comments below!