Feeders: Injecting Test Data Into Gatling Sessions
Inject per-user test data with Gatling feeders: CSV, JSON, JDBC, Redis sources and queue, random, shuffle, or circular strategies for realistic load tests.
Use this file to discover all available pages before exploring further.
Feeders are Gatling’s mechanism for supplying each virtual user with unique, realistic test data—usernames, search keywords, product IDs, addresses, and anything else that makes your load test representative of real traffic. A feeder is fundamentally an Iterator<Map<String, Object>>: each time a virtual user reaches a feed step in the scenario, it polls one record from the iterator and injects every key-value pair from that record into its Session as new attributes. Those attributes are then available throughout the rest of the scenario via EL expressions such as "#{username}".
The Writing realistic tests guide walks through practical examples of combining feeders with scenario logic.
The feed method is called in a scenario chain at the same position as exec. Every virtual user that reaches this step picks up the next available record.
Every file-based feeder supports four strategies that control how virtual users pick records. The strategy is applied by chaining it after the feeder builder.
queue (default)
random
shuffle
circular
Each user consumes a unique record in file order. Records cannot be reused. The test crashes if more records are requested than available.
csv("users.csv").queue()
Use when: credentials or IDs must not be shared between users.
Each user picks a random record. Records can repeat; the feeder never runs out.
csv("keywords.csv").random()
Use when: you don’t mind duplicate data (e.g., search terms).
Like queue but the order is randomized upfront. Records are still consumed uniquely. Crashes when exhausted.
csv("users.csv").shuffle()
Use when: unique records are required but order doesn’t matter.
Records are consumed in file order, wrapping back to the start when the end is reached. Records can repeat.
csv("products.csv").circular()
Use when: you want sequential order but with an unlimited supply.
Both queue and shuffle will cause Gatling to crash if you try to consume more records than the feeder contains. Size your data files appropriately for your virtual user count.
When running distributed tests with Gatling Enterprise, use shard to split the dataset across load generators so no two generators use the same records:
Java
csv("data/users.csv").shard()
For example, 30,000 records split across 3 load generators gives each one a unique 10,000-record slice.
shard is a no-op when running locally with the Community Edition. It only has effect on Gatling Enterprise.
Apply transformations to raw feeder values before they are injected into the Session. This is useful when the source format (e.g., CSV strings) doesn’t match the type your requests expect.