top of page

Performance Testing Kafka Using Gatling

Currently, Gatling does not support load testing for the Kafka application Out-of-Box. This can be an issue as Kafka is highly used which only increases the need to ensure the performance is succeeding. Now, despite Gatling not supporting Kafka, we can still load-test it with the use of a plugin by the creator 'rutinkoff'.



Implementing this plugin can be challenging, but it runs smoothly once it is up and running.

The power that the plugin provides makes Gatling even more versatile than it already is along with helping you understand how your Kafka environment is performing. This in itself makes this plugin optimal to implement.


To implement this, there are several steps to follow:

  1. Create a new Maven environment or use an existing project

  2. Add rutinkoff dependency to the project's POM file

  3. Match Gatling and plugin versions


Create a new Maven environment


Ensure that IntelliJ is installed. Go into IntelliJ and go to File > New > Project and configure the settings as indicated here (Note: The JDK can be whichever you choose):


Add Rutinkoff dependency to POM file


Navigate to your project's POM file and enter the following under the <dependencies> tag:

<dependency>
  <groupId>ru.tinkoff</groupId>
  <artifactId>gatling-kafka-plugin_2.13</artifactId>
  <version>0.9.0</version>
</dependency>

You can use whichever version you desire, but in this case it was 0.9.0.


Ensure Gatling version matches plugin


One problem that occurred was which version to use in Gatling. You can solve this easily by looking at the POM file of the plugin and ensure that you are using the same version as indicated in the plugin.


From here, you can build your project to ensure the dependency is pulled which will help resolve any import errors. You then have the freedom to implement load tests to run on your Kafka environment.


Script Example


The following is an example that uses a scenario to write to a topic.


val scn: ScenarioBuilder = scenario("Basic")
  .feed(feeder)
  .exec(
    kafka("ReqRep").requestReply
      .requestTopic("Test")
      .replyTopic("Test")
      .send[String, String]("#{kekey}", """Test event""")
  )

If we look at this scenario that you can find at the plugin's GitHub page, there are a few things that we can discern. It creates a scenario which is familiar to Gatling by adding the 'kafka' in the exec.

This example demonstrates a load test that is sending the String "Test event" to the topic "Test".

One thing to note is that if the topic does not exist, it will create it which means you don't have to test topics that have previously been created.


Final Notes


Using this plugin to support Gatling testing Kafka is not only efficient, it is also optimal. It is the version that Gatling recognizes as the unofficial plugin which ensures that it is being updated regularly and you can trust the plugin to act well. To view the source code for the plugin and to look at other test scripts, you can go to https://github.com/Tinkoff/gatling-kafka-plugin.

316 views0 comments

Recent Posts

See All

Hozzászólások


bottom of page