Contents

Introducing ZeroMQ connector for Gatling

Connector

Origins

ZeroMQ

One of our recent projects heavily uses ZeroMQ, a platform for distributed messaging and computation. In short, it provides sockets able to handle the sending/receiving of messages across numerous transport protocols. Sockets can be connected in accordance with various messaging patterns, like fan-out, pub-sub or request-reply.

ZeroMQ logo

We have decided to adapt ZeroMQ because of its simplicity, scalability features and efficiency of message handling. There are API implementations in many languages. Since we are working within the JVM, we use JeroMQ written in Java.

Gatling

To check application performance, we had to run a number of load tests for it. There is a really good tool created for this task - Gatling. It is written in Scala, works in an asynchronous stack and provides a quite rich DSL. Thanks to this we are able to create test scenarios quickly, and easily scale them up to thousands of virtual users working with our system. For a more detailed review of Gatling, I really recommend you to watch the presentation of our Andrzej Ludwikowski from the Scalar Conference.

Gatling logo

All of the Gatling’s features sounded like a perfect match for our project. The only missing piece for us was a connector between it and ZeroMQ.

Connector

And here it is. Yet another open source project from SoftwareMill. We are releasing gatling-zeromq, a plugin for Gatling that allows running tests with the ZeroMQ protocol.

Current state

Starting point is com.softwaremill.gatling.zeromq.Predef singleton object. It provides two methods: zmqConfig() to create a ZeroMQ protocol’s configuration and zmq(requestName) to build a request sent during tests.

The current version of the plugin supports a publisher of a publish-subscribe message pattern only. Tests require a host and a port of the subscriber. Both can be provided with a configuration:

val config = zmqConfig
   .host(“localhost”)
   .port(8999)

Then, the config variable is used to define a protocol for Gatling's scenarios:

  setUp(
    // scenario injection...
  ).protocols(config)

Messages can be sent in two ways: individually and as a multi-part message. Here is an example how you can do this, respectively, with a DSL provided by the plugin:

scenario("A")
   .exec(
      zmq("Stock quote A")
         .send("${company.random()}: ${price.random()}")
   ) 

scenario("B")
   .exec(
      zmq("Stock quote B")
         .sendMore("${company.random()}")
         .send("${price.random()}")
   )

When it comes to test data, you can use String, Array[Byte], or numeric data types.

Although you can provide static messages, a better idea is to use dynamic data so you won’t be testing the same scenario for every request sent. gatling-zeromq supports Gatling’s Expression Language syntax and is able to resolve expressions in a message like ${companies.random()} or ${companies(2)}.

What’s next?

There are not too many features available at the moment, but we treat it as a starting point in the plugin’s development.

You can participate in gatling-zeromq development as well!

If you have a new feature idea - post an issue on GitHub. Or - even better - make a pull request to the project!

And let us know your opinion on the project in comments.

Blog Comments powered by Disqus.