I have this gatling code (mostly taken from here: https://github.com/gatling-cql/GatlingCql):
val feeder = Iterator.continually(
Map(
"id" -> serialGen(),
"randomString" -> random.nextString(20),
"randomNum" -> jrandom.nextLong(),
"randomMap" -> maps(jrandom.nextInt(maps.size))
))
val scn = scenario("Two statements").repeat(1) {
feed(feeder)
.exec(cql("simple SELECT")
.execute("SELECT * FROM test_table WHERE id = ${randomNum}")
.consistencyLevel(ConsistencyLevel.LOCAL_QUORUM)
.check(rowCount.satisfies(a => a >= 0)))
.exec(cql("prepared INSERT")
.execute(prepared)
.withParams("${id}", "${randomMap}", "${randomString}")
.consistencyLevel(ConsistencyLevel.LOCAL_QUORUM))
}
setUp(scn.inject(
rampUsersPerSec(1) to 1 during (1.minute)
)).protocols(cqlConfig)
And the repeat(1)
thing causes only 2 statements (simple SELECT and prepared INSERT, as defined above) to be executed per user per second. If I do repeat(300)
there will be 600 statements per user per second.
What I want is for this code to execute as many as possible statements per second. What modifications do I need to make this this code to achieve that?
Looks like using doWhile
instead of repeat
achieves this:
val feeder: Iterator[Map[String, Any]] = Iterator.continually(
Map(
"id" -> serialGen(),
"randomString" -> random.nextString(20),
"randomNum" -> jrandom.nextLong(),
"randomMap" -> maps(jrandom.nextInt(maps.size))
))
val scn = scenario("Two statements").doWhile(true) {
feed(feeder)
.exec(cql("simple SELECT")
.execute("SELECT * FROM test_table WHERE id = ${id}")
.consistencyLevel(ConsistencyLevel.LOCAL_QUORUM)
.check(rowCount.satisfies(a => a > 0)))
.exec(cql("prepared INSERT")
.execute(prepared)
.withParams("${id}", "${randomMap}", "${randomString}")
.consistencyLevel(ConsistencyLevel.LOCAL_QUORUM))
}
setUp(scn.inject(
atOnceUsers(10)
))
.protocols(cqlConfig)
.maxDuration(30.seconds)
after(session.close())
}