Hi ,
I am trying to simulate the load for rest API Post request call to OPETSDB to add time series test data in millions as part of quick POC. I found Gatling might be right tool for this job since it is based on scala and Akka framework , can spawn requests very quickly and trying with this tool.
I have written example program where body () should be populated with dynamic values from feeder .
val scn = scenario("Simulation for the opentsdb datapoints post service").feed(myCustomFeeder).repeat(repeatCount) {
exec(
http(session => "Post a DataPoint")
.post(customerLink)
.body( StringBody("""{
"metric": "${metric}",
"timestamp": "${timestamp}",
"value": "${value}" ,
"tags": {
"host": "${host}",
"if": "${if}"
}
}"""))
.check(status is 200)
) }
-----------------------------------------------------------------------------------
import io.gatling.core.feeder._
val myCustomFeeder = new Feeder[String] {
import scala.util.Random
override def hasNext = true
override def next: Map[String, String] = {
val index = Random.nextInt(4)
val preDeftagVals = preDefTagValset(index%2)
val timeDelta = Random.nextInt(120* 60* 1000)
Map("metric" -> preDefinedMetrics(index), "timestamp" -> s"${Calendar.getInstance().getTimeInMillis()-timeDelta}" , "value"-> s"${prefDefinedValues(index)}" , prefDefTagKeys(0) -> preDeftagVals(0), prefDefTagKeys(1) -> preDeftagVals(1))
}
}
-------------------------------------------------------
Note : preDefinedMetrics() method in this example is just few records for testing. All values will be generated be dynamically for each request like "timestamp" value for each one second.
Issue : Post request with dynamic values for each repeat request of each user to rest api call.
This above code with feeder is injecting one record into session for each user based on number of threads configured. Means if I have 10 users each user session record values are different. But the issue is if I repeat the request for 10 times with repeat count for the scenario for user all 10 post requests have same data in post request parameters.
I can't expect 1 million users for one million records to call rest api with different dynamic parameter values .
Please suggest or point me to example how can I make sure all my post request parameter values will be dynamically set while post request is firing Rest API call.
I am pretty now to this Gatling tool , but I considered this for evaluation due to it's scala , akka framework. I am sure there will some kind of solution since this is pretty basic scenario.
Also populating data to CSV file ( ten million records ) and using csv feeder for making those records available in session does not look right for me. So there should a way to feed data dynamically in each post request right. I tired to define a method for data generation and call that from body() , but it is injecting only one record for all requests.
Thanks
Krishna Prasad