Reputation: 40061
I struggle with what seems like an easy thing to do.
I'd like to ramp up the number of concurrent calls to an api over time until it breaks.
From my understanding this is rampUsersPerSec
with a low initial rate increasing to something high enough to break it with during
long enough to see when it actually breaks.
This is my code
val httpProtocol = http
.baseUrl("http://some.url")
.userAgentHeader("breaking test")
.shareConnections()
val scn = scenario("Ralph breaks it")
.exec(
http("root page")
.get("/index.html")
.check(status.is(200))
)
setUp(
scn.inject(
rampUsersPerSec(1) to 100000 during (10 minutes))
.protocols(httpProtocol))
Two things happen
Upvotes: 1
Views: 1300
Reputation: 2604
When you use rampUsersPerSec you are defining the arrival rate of users. So with 'rampUsersPerSec(1) to 100000 during (10 minutes))' gatling will inject 1 user per second at the start, and gradually increase the rate until at 10 minutes in it is injecting 100,000 users per second.
Depending on the time it takes for your call to /index.html to respond, this could very quickly out of hand as gatling isn't waiting for the users already injected to actually finish - it just keeps adding them regardless. So (roughly) in the first second gatling might inject 1 user, but then in the 2nd it might inject 166, and in the 3rd 333 users and so on. So if your scenario takes a few seconds to respond, the number of concurrent users can increase rapidly.
Unfortunately, I don't think there's any way to have the simulation detect when you've hit a defined error rate and stop. You would be better having a much slower ramp over a longer duration. Alternatively, you could use the closed form injection methods that target a given level of concurrency rather than arrival rate
Upvotes: 1
Reputation: 80
I'm doing similar thing to yours and I managed to solve that using below code
private val injection = incrementConcurrentUsers(1)
.times(56)
.eachLevelLasting(1700 millis)
.startingFrom(10)
Upvotes: 0