Parameterizing Gatling Simulations with CSV Feeders: Modes, Placeholders, and Cluster Pitfalls
Use CSV feeders in Gatling to inject per‑user data into HTTP requests. This guide covers feeder modes (queue, circular, random, shuffled, eager), placeholder substitution, a complete Scala simulation example, cluster partitioning pitfalls, and verification steps.
05 Mar 2026, 01:35 UTC

The problem: hard‑coded test data limits realism
Load tests that reuse the same credentials or payload for every virtual user hide contention, caching, and validation bugs. Gatling solves this with feeders — components that read external data (CSV, JSON, JDBC, etc.) and expose each row as session attributes for the current virtual user. A CSV feeder is the simplest way to vary usernames, passwords, product IDs, or any columnar data without changing simulation code.
How CSV feeders work
At simulation start Gatling loads the CSV file into memory. Each row becomes a map of column‑name → value. When a scenario executes feed(csv("users.csv").circular), the feeder assigns the next row’s columns to the virtual user’s session. Later, any string containing #{columnName} — in a URI, header, or request body — is replaced with that session attribute just before the HTTP request is sent.
Worked example: login simulation with circular feeder
Assume src/test/resources/data/users.csv (relative to the Gatling project root):
username,password
alice,secret1
bob,secret2
carol,secret3
Scala simulation (Gatling 3.9+ / 4.x compatible):
package com.example
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class LoginSimulation extends Simulation {
val httpConf = http.baseUrl("https://api.example.com")
val loginFeeder = csv("data/users.csv").circular
val scn = scenario("Login")
.feed(loginFeeder)
.exec(http("POST /login")
.post("/login")
.header("Content-Type", "application/json")
.body(StringBody("""{"username": "#{username}", "password": "#{password}"}""")).asJson
.check(status.is(200)))
setUp(scn.inject(atOnceUsers(10))).protocols(httpConf)
}
Each of the 10 virtual users pulls the next CSV row (wrapping around because of .circular) and sends a distinct JSON payload. The placeholders #{username} and #{password} are resolved from the session at request time.
Feeder modes and when to use them
| Mode | Behavior | Typical use case |
|---|---|---|
queue (default) | Sequential, fails when exhausted | Fixed‑size datasets where each row must be used exactly once |
circular | Repeats indefinitely | Long‑running tests or when user count > row count |
random | Random row per access | Unpredictable access patterns |
shuffled | Randomized order once, then repeats | Even distribution without immediate repeats |
eager | Preloads all rows into memory | Small files where lookup speed matters |
Choose circular for most load tests; it prevents the no‑more‑elements error that stops a virtual user when a queue feeder runs dry.
Common mistakes and how to avoid them
- Queue mode with insufficient rows – users fail with
Feeder[Map[String, Any]] is empty. Fix: switch to.circularor ensure row count ≥ total iterations. - Placeholder typo –
#{userName}vs#{username}causes a resolution error. Fix: match CSV header exactly (case‑sensitive). - Distributed cluster without partitioning – each Gatling node loads the full CSV, so all nodes feed the same rows. Fix: split the CSV per node (e.g.,
users-node1.csv,users-node2.csv) or use a shared JDBC feeder. - Large binary payloads in CSV – feeders are text‑oriented and keep rows in memory. Fix: store blobs in separate files and reference them via a file feeder or
RawFileBody. - Version mismatch – method signatures for
circular,shuffleddiffer between Gatling 3.x and 4.x. Fix: check the major version in your build (gatling.versionproperty) and consult the corresponding release notes.
Verification steps
- Run the simulation with
gatling.sh -s com.example.LoginSimulation(or via Maven/Gradle). - Open the generated HTML report (
target/gatling/.../index.html) and check the Request tab: each login request should show a different username in the request body. - For queue‑mode exhaustion test, create a 2‑row CSV, inject 5 users with
.queue, and confirm 3 users fail with a feeder‑exhaustion error in the simulation log. - In a cluster, add a unique node identifier to each CSV (e.g.,
username,password,node) and verify that rows are not duplicated across nodes by grepping the simulation log for the node column.
Limitations
- CSV feeders load the entire file at startup; changes to the file during a run are ignored.
- Memory usage grows with row count and column width — avoid multi‑megabyte CSVs in
eagermode. - No built‑in support for relational joins; use a JDBC feeder if you need correlated data from multiple tables.
Quick checklist before scaling
- CSV headers match placeholder names exactly.
- Feeder mode matches test duration and user count (prefer
circular). - Row count ≥ expected iterations if using
queue. - Cluster nodes have partitioned data files or a shared external feeder.
- Gatling major version confirmed; feeder API matches that version.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.