Using Gatling for load testing hundreds permanent connections

Hello group,

I am new to this group, and new to Gatling (using version 2.1.7 at the moment).

I want to use Gatling to perform a continuous load test on a Zookeeper cluster, simulating hundreds of connected clients that periodically execute requests (like querying the zookeeper content, adding/removing ephemeral nodes).

At the moment I have a test scenario running, but it is creating a new connection for each request. And that is not simulating the actual production usage accurately.

What is the proper way to model the following behaviour in Gatling (if at all possible):

  • Initialize the Zookeeper cluster (pre-load it with data)

  • Spin up 200 client connections that remain active and are reused

  • For 6 hours have these 200 clients perform requests to Zookeeper every couple of minutes

  • Preferably I create several types of clients (i.e. one or two ‘heavy hitters’, a bunch of ‘frequent users’ and a large group that hardly does anything except keeping the connection active)- Stop/close the clients

  • Finish the testrun
    Should I create a scenario per client, or per type of client? How would I translate the gatling load injection to client actions?

I have created a plugin setup similar to the gatling-kafka plugin available on Github, but struggle with the ‘1 request == 1 new connection’ of that setup. The connection is made at execution time (in the executeOrFail implementation).

Apologies for the rather abstract question, any pointers to documentation that explains how this kind of simulation is possible is appreciated.

I appreciate that Gatling is primarily geared to HTTP load testing, which is a rather ‘connection-less’ protocol, so support for my requirements may not be easy.



Hi Jean-Marc,

Have you gone any further with this approach? I’m facing a quite similar scenario and I’m very interesting.

Thank you in advance. Regards,


Use atOnceUsers(200), loop your request with a pause and set maxDuration to 6 hours.


I presume that the Zookeeper client is a TCP client that keeps a long-running connection and transfers data over it periodically. And, there is some sort of heartbeat to keep the connection up?

For a custom TCP server we have, we had to develop a Java library which maintained a thread for each TCP connection and implemented the custom binary protocol.
This library was integrated with Gatling’s async “virtual users”.

It took a single developer over three months to implement this customized gatling module and java library.


It took a single developer over three months to implement this customized
gatling module and java library.

You'd should have contracted with us :slight_smile: :slight_smile: :slight_smile:

*Stéphane Landelle*
*GatlingCorp CEO*

Hi Alberto,

(I was on holiday, so apologies for the late reply).

Yes, I have successfully created a Protocol + RequestActionBuilder + RequestBuilder to use a single zookeeper connection and have Gatling send multiple requests through it during simulations.
Unfortunately the code is currently closed under NDA as it belongs to my employer. I’ll see if I can reproduce it in my spare time (it’s not very complicated, and definitely did not take more than a couple of hours to write; nowhere near the three months Sajjad reported).

Please note that we used Gatling 2.1.7 at the time, to connect to Zookeeper 3.4.6.

I’ve since moved to other areas and am not actively using that code anymore, but I will try to find some time this week to put something on Github.



Hi Jean-Marc,

thank you very much for replying. It would be awesome if you can share the code in github. Let me know if I can give you a hand!

Kind regards,



I’ve posted a Gist:

It shows the general approach, not the direct Zookeeper connection handling, as that is part of our internal client library (NDA :frowning: ). But the approach should be clear enough to get you going and create a reusable zookeeper connection.