Feeding scenario from stdin


How can I use a feeder which reads from stdin with a gatling scenario? The way simulations are invoked via the interactive dialogue it’s not evident how to pipe data as input but I am guessing it’s possible.

Thank you,


Could you explain why you’d want to do such a thing, please?

I want to pipe the output of an application into my simulation. The feeder is setup to read either from file or stdin.

In more detail: We have a web application running in production - this application logs every http request it receives to file - I want to tail this log into the Gatling simulation where it’s converted by the feeder into http requests to the development version of the very same web application. With this setup I could thus expose production and development version to the same http hits and verify that they behave in the same way.

Of course, I could do the same with pre-recorded log files but for certain aspects of testing it could be helpful to just pipe the production log into gatling.


Everything is feasible, of course, but still, I’m not sure that’s a good idea…


  • Input:

  • Reading STDIN means getting an InputStream

  • Decode your bytes with an InputStreamReader

  • As your input is incomplete at some points in time (tail), you might end up with broken lines, so you might have to push back some chars (PushBackReader).- Output:

  • A Feeder[T] is a type alias for Iterator[Map[String, T]].

  • You’d have to parse your lines (this is the easy part)

Yep, could be it’s not a great idea :wink: In any case, I kind of figured it out. My problem was more about how to invoke gatling while reading from stdin than with the implementation of the feeder itself.




How do I set up a scenario which just feeds the simulation with events from stdin at the rate at which they arrive?

I can feed from stdin without problem, see code below, however, I am required to set the user rate for the simulation to start. If I set it too high Gatling will complain about the feeder being empty, if I set it too low it will lag behind the input source. Ideally, I don’t want to set users/throttling explicitly at all. I just want the simulation to run for Simulation#maxDuration( seconds) while reading from stdin.

I do like this:

This is a stream which does not end.

wget -qO - | ./bin/gatling.sh – simulation mySimulation

and inside mySimulation the feeder is defined as:

val feeder = scala.io.Source.stdin.getLines.map(line => scala.util.parsing.json.JSON.parseFull(line).get.asInstanceOf[Map[String, Any]])

with the setup like:

scn.inject(constantUsersPerSec(1000.0) during(10 seconds)).protocols(httpConf) //don’t really want to set this
// scn.inject(nothingFor(0 seconds)) // does not even start simulation
.maxDuration(10 seconds)

Is this doable and how? Thanks,


Currently not doable.