Gatling exposes performance tradeoffs by exercising an application end to end rather than measuring isolated code. It helps test whether optimizing a high-traffic endpoint produces more benefit than optimizing a slower, rarely used one. section 7.2.3
A practical Gatling simulation defines:
- A Scala class extending Simulation. section 7.2.3
- An HTTP protocol with a base URL and JSON headers. section 7.2.3
- Scenarios that issue requests and check expected responses, such as HTTP 200. section 7.2.3
- Traffic profiles matching expected demand, such as one request per second versus twenty requests per second. section 7.2.3
Listing 7.9 Getting the word-of-the-day’s performance
class WordsSimulation extends Simulation {
val httpProtocol = http
.baseUrl("http://localhost:8080/words")
.acceptHeader("application/json")
val wordOfTheDayScenario = scenario("word-of-the-day")
.exec(WordOfTheDay.get)
object WordOfTheDay {
val get = http("word-of-the-day").get("/word-of-the-day").check(status is 200)Shows a minimal word-of-the-day simulation with an HTTP request, JSON acceptance, and response validation. section 7.2.3
