JMeter Kafka Load Testing

Kavindu Gayan
4 min readNov 2, 2023

Step 1: Install Jmeter plugin manager

Download the JMeter Plugin Manager from https://jmeter-plugins.org/install/.

Copy the downloaded plugin manager into the /lib/ext/ folder of your JMeter installation.

Restart Jmeter.

After restarting, go to Options -> Plugin Manager to verify that the plugin manager is available.

Step 2: Enable Kafka Producer Sampler in Plugin Manager

Options -> Plugin Manager

Step 3: Create ‘Thread Group”

Right click on Test plan Add -> Treads (Users) -> Thread Group

You can edit the Thread Group properties:

Number of Threads (Users):

This setting specifies the total number of virtual users (threads) that will be executing the test plan concurrently. Each thread represents a virtual user interacting with the target system.
For example, if you set the Number of Threads to 100, JMeter will simulate 100 concurrent users making requests to your target application.

Ramp-up Period:

The ramp-up period is the time it takes to gradually increase the number of threads (users) from zero to the specified total (Number of Threads). It defines the interval (in seconds) over which new threads will be started.
For example, if you set the Number of Threads to 100 and the Ramp-up Period to 10 seconds, JMeter will start 10 threads every second until all 100 threads are running. This gradual increase in load helps simulate a more realistic scenario, similar to how real users may access an application over time.

Loop Count:

The Loop Count specifies the number of times each thread will execute the test plan within the Thread Group. Each execution of the test plan is often referred to as an “iteration” or “loop.”
By default, a Thread Group executes the test plan once (Loop Count = 1). You can set it to a specific number (e.g., 5) to have each thread repeat the test plan that many times.
Here’s an example to illustrate how these settings work together:

Number of Threads: 50
Ramp-up Period: 5 seconds
Loop Count: 3

In this scenario, JMeter will start 10 threads (50 / 5) every second for 5 seconds, reaching a total of 50 threads. Each of these 50 threads will execute the test plan 3 times (Loop Count), making a total of 150 iterations of the test plan.

These settings allow you to control the load generated by your performance test and how it is distributed over time. It’s important to consider these settings carefully to simulate real-world scenarios and understand how your system behaves under different levels of concurrent user activity.

Step 4: Add Kafak producer sampler

Right click Thread Group -> Sampler -> Kafaka Producer Sampler

Here you can add

Kafka Topic: The name of the Kafka topic to which the messages will be sent.

Key: The message key, which is an optional attribute used for partitioning and message routing in Kafka.

Message: The message content that you want to send to the Kafka topic.

Partition String: is a parameter that allows you to specify the partition to which a message should be sent within a Kafka topic.

Step 5: Add Listener

Finally you can add the listener to verify the result.

There are several listeners you can use to monitor and analyze the performance of your Kafka tests. The choice of listener depends on your specific testing and reporting needs. Here are some commonly used JMeter listeners for Kafka testing:

View Results Tree:

The “View Results Tree” listener is a versatile listener that allows you to view detailed information about each request/response in a tree format. While it’s not specifically designed for Kafka, it can be used to inspect individual Kafka requests and responses.

Summary Report:

The “Summary Report” listener provides a summary of the test results, including metrics like throughput, average response time, and error counts. It can be useful for getting a quick overview of your Kafka test’s performance.

Response Times Over Time:

The “Response Times Over Time” listener visualizes the response times of your Kafka requests over the duration of the test. It’s helpful for identifying performance trends and potential bottlenecks.
Response Times vs Threads:

The “Response Times vs Threads” listener shows how response times are affected as the number of threads (virtual users) increases. This can be helpful for understanding how Kafka performance scales with concurrency.

JP@gc Kafka Connect:

The “JP@gc Kafka Connect” listener is specifically designed for Kafka testing. It provides detailed information about Kafka producers and consumers, including message rates, latencies, and errors.

--

--