Book Image

Master Apache JMeter - From Load Testing to DevOps

By : Antonio Gomes Rodrigues, Bruno Demion (Milamber), Philippe Mouawad
Book Image

Master Apache JMeter - From Load Testing to DevOps

By: Antonio Gomes Rodrigues, Bruno Demion (Milamber), Philippe Mouawad

Overview of this book

Load tests help identify the maximum number of requests a software system can handle. One popular open source tool for load testing is JMeter. By leveraging the features and capabilities of JMeter, you can perform extensive load testing and fix issues in your application before they become problematic. This book is written by JMeter developers and begins by discussing the whole process, including recording a script, setting it up, and launching it, enabling you to almost immediately start load testing. You'll learn the best practices that you must follow while designing test cases. You'll also explore the different protocols offered by JMeter through various real-world examples. Finally, you'll see how to integrate JMeter into the DevOps approach and create professional reports. You'll discover ways to use the eco-system of JMeter to integrate new protocols, enrich its monitoring, and leverage its power through the use of the cloud. By the end of this book, you'll know all that's needed to perform comprehensive load testing on your applications by using all the best practices and features of JMeter.
Table of Contents (14 chapters)

Setup Our Load Test and Launch It

  1. To set up our load test, select the Thread Group element in order to change the following values:

    Number of Threads (users): 10

    Ramp-Up Period (in seconds): 10

    Loop Count: 100

    This gives 10 virtual users (VU) who arrive in 10 seconds (1 per second), and each one will make 100 executions of the query sequence.

    Figure 1.27: Load test parameters
    Figure 1.27: Load test parameters

    Caution

    Several strategies for setting the load test exists. This point will be discussed deeply in Chapter 2, JMeter Overview.

  2. We could run our load test directly from the JMeter GUI, but this is not recommended as it would not be optimal for performances of injection (although, in our case, with only 10 users, it shouldn't be a problem).
  3. When load testing, it is advisable to monitor the injectors (servers where JMeter runs) at least during the first test at full load to validate the correct behavior of the injectors.

    This ensures that if we get bad response times, the cause is the application being tested and not JMeter.

    Note that this is not specific to JMeter but should be done regardless of the tool you use.

    Note

    An easy and quick solution to monitor JMeter can be to use the Servers Performance Monitoring plugin from the JMeter Plugins (https://jmeter-plugins.org/wiki/PerfMon/).

  4. So, let's use best practices directly and run our test from the command line in CLI mode (also called Non-GUI mode in JMeter).
  5. But before that, to follow our test in real time, we will add the Backend Listener element to enable live monitoring of the progress of the test with Grafana (https://grafana.com/).
  6. To do this, right-click on Test Plan -> Add -> Listener -> Backend Listener:
    Figure 1.28: Add Backend Listener
    Figure 1.28: Add Backend Listener
  7. Let's configure it to send the test results to our InfluxDB database (https://www.influxdata.com/):
Figure 1.29: Backend Listener configuration
Figure 1.29: Backend Listener configuration

Note

In the samplersRegex field, we can use a regular expression to keep only the queries that were recorded by the HTTP(S) Test Script Recorder element (thanks to Prefix: field).