Hello everyone, in our previous post Accelerate performance with Gatling: POST HTTP REQUEST we have discussed:
In this post, we will discuss:
Let’s assume that we are simulating a use case where 1000 concurrent users are trying to register to the app. Now there are two ways to do that: one is to write a random string method and use it in our simulation and the other is to separate the data from our simulation by defining a feeder.
The feeder is a type alias for Iterator[Map[String, T]]. Gatling DSL provides an easy to use ‘feed’ method which takes the feeder as an argument and reads the data from the feeder and injects it into the simulation.
Gatling provided multiple feeders
Gatling provides various ways to read the data from character-separated values files. Now there are multiple use cases where we use different separator characters in our data files like | ‘ : @ # $ etc.
So we can use
If we have large data files then you can use zip file in Gatling feeder and ask Gatling to unzip the data at run time using following syntax
Above we have seen how to send the data from the different files, but what if a user wants to use a JSON file as a feeder? Just like CSV feeder, Gatling has a JSON feeder that can inject the data from JSON file or a JSON URL with the following syntax:
As the name said JDBC feeder provides the capability to read the data from JDBC connections. It means if a user wants to read the data from a database like MySQL or PostgreSQL they can use JDBC feeders that will take the connection URL, user credentials and query as an input and at run time it will connect with the database as per defined configuration and inject the data in the simulation.
Gatling supports some other feeders as well, but those are dependent on the use case where if a user wants to read a sitemap file using sitemap feeders, to read data from Redis using Redis feeders and to define a custom feeder as per the use case.
#scala #gatling feeder #json feeders