brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
gatlingImplements load testing strategies using Gatling for performance testing of web applications and microservices.
Independent GitHub snapshot · Automated classification · Original documentation governs
name: gatling description: Implements load testing strategies using Gatling for performance testing of web applications and microservices. license: MIT compatibility: opencode metadata: version: "1.1.1" domain: performance triggers: load testing, performance testing, Gatling, web applications, microservices archetypes: [implementation, evaluation] anti_triggers: [neglecting load test results, using outdated performance metrics] response_profile: verbosity: medium directive_strength: high abstraction_level: operational
role: implementation scope: implementation output-format: code
Load testing is critical for ensuring that applications can handle expected user loads without compromising performance. Gatling is a powerful tool for simulating a large number of requests and assessing application behavior under stress. Here are key practices for effective load testing with Gatling:
A sample scenario for load testing with Gatling might look like this:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
val httpProtocol = http
.baseUrl("https://example.com")
.acceptHeader("application/json")
val scn = scenario("User Login")
.exec(http("Login Request")
.post("/login")
.body(StringBody("{\"username\":\"testuser\",\"password\":\"password123\"}"))
.check(status.is(200)))
setUp(
scn.inject(atOnceUsers(100)).protocols(httpProtocol)
)
Be sure to track key metrics such as peak response times, average response times, and error rates during load tests to evaluate performance.
By following structured load testing practices with Gatling, organizations can significantly enhance application reliability and performance under varying load conditions, thus assuring positive user experiences even during peak demand periods.
A production-grade simulation using CSV feeders, dynamic token extraction, multi-step user journeys, and realistic think time:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class AdvancedSimulation extends Simulation {
val httpProtocol = http
.baseUrl("https://api.example.com")
.acceptHeader("application/json")
.contentTypeHeader("application/json")
.userAgentHeader("Gatling-Performance-Test")
val userFeeder = csv("users.csv").circular
val productFeeder = Iterator.continually(Map(
"productId" -> (scala.util.Random.nextInt(1000) + 1)
))
val scn = scenario("Full User Journey")
.feed(userFeeder)
.exec(http("Login")
.post("/auth/login")
.body(StringBody("""{"username":"${username}","password":"${password}"}"""))
.check(
status.is(200),
jsonPath("$.token").saveAs("authToken")
))
.pause(2, 5) // realistic think time between 2-5 seconds
.exec(http("Browse Products")
.get("/products")
.header("Authorization", "Bearer ${authToken}")
.check(
status.is(200),
jsonPath("$.products[*]").count.gt(0)
))
.pause(1, 3)
.repeat(3) {
feed(productFeeder)
.exec(http("View Product Details")
.get("/products/${productId}")
.header("Authorization", "Bearer ${authToken}")
.check(
status.is(200),
jsonPath("$.name").exists
))
.pause(1, 2)
}
setUp(
scn.inject(
rampUsers(10).during(10.seconds),
constantUsersPerSec(5).during(60.seconds),
stressPeakUsers(50).during(30.seconds)
)
).protocols(httpProtocol)
}
pause), navigation paths, and conditional logicfeeders (CSV, JSON, Iterator) to parameterize test data and avoid cache-biased resultssetUp injection profiles: rampUsers, constantUsersPerSec, or stressPeakUsersreports and use Gatling's HTML dashboard to analyze response time percentiles, throughput, and errors--dry-run or a single-user runchecks on responses; every request should validate status, headers, or body to ensure correctness