Load testing our robots API with Gatling

Posted on by  
Tammo Sminia

In a previous blog post we made an API with spray. Now we're going to load test it. For this, we will use In a scala class we can write exactly what and how we want to run the test. In this test, we will do a post to our API and create a new robot called C3PO. We will do this 1000 times per second and keep doing this for 10 seconds. For a total of 10000 C3POs! RobotsLoadTest.scala:

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class RobotsLoadTest extends Simulation {
    val baseUrl = "http://localhost:8080" //We need to have our API running here

    val httpProtocol = http
        .userAgentHeader("Apache-HttpClient/4.1.1 (java 1.5)")

    val s = scenario("Simulation")
                        |  "name": "C3PO",
                        |  "amountOfArms": 2

    setUp(s.inject(constantUsersPerSec(1000) during(10 seconds))).protocols(httpProtocol)

Continue reading →