Prev Next

Testing / Distributed Performance Testing with Gatling Interview questions

Last updated

1. What is distributed performance testing? 2. What is Gatling? 3. What are the limits of a single load generator? 4. What is a Gatling simulation? 5. What are injection profiles in Gatling? 6. What is the difference between open and closed workload models? 7. What are the main components of a distributed Gatling setup? 8. What is an injector in Gatling? 9. How do you run a Gatling simulation from Maven? 10. What is a feeder in Gatling? 11. What are checks in Gatling? 12. What are assertions in Gatling? 13. What is the simulation.log file in Gatling? 14. What is the difference between a scenario and a simulation? 15. What key metrics should you watch in a distributed Gatling run? 16. What are the common ways to run Gatling in distributed mode? 17. What is Gatling Enterprise? 18. How do you split load across multiple Gatling injectors? 19. How do you merge Gatling results from multiple injectors? 20. Explain the execution flow of a distributed test with open-source Gatling? 21. How do you split feeder data across injectors to avoid duplicates? 22. Which feeder strategy is better in distributed tests: queue or circular? 23. How do you handle session tokens and shared state across injectors? 24. How do you synchronize start times across Gatling injectors? 25. Why does clock synchronization matter across Gatling injectors? 26. Explain the internal working of Gatling's engine for handling many users? 27. How do you detect an overloaded Gatling injector? 28. How do you size injectors for a target requests-per-second? 29. Why should you tune JVM heap and GC settings on Gatling injectors? 30. How do you avoid port exhaustion on Gatling injectors? 31. When should you use shareConnections in Gatling? 32. Why does coordinated omission matter in Gatling tests? 33. When would you choose Gatling Enterprise over open-source Gatling? 34. What is the difference between Gatling and JMeter for distributed testing? 35. How does Gatling Enterprise distribute a test across injectors? 36. How do you run Gatling injectors in Docker? 37. How do you run distributed Gatling on Kubernetes? 38. How do you run distributed Gatling tests in a CI/CD pipeline? 39. What happens when one injector fails in the middle of a Gatling test? 40. How do you simulate geographically distributed users with Gatling? 41. How do you use assertions as pass/fail gates across a distributed run? 42. When should you use throttle instead of injection profiles? 43. What is the difference between rampUsers and rampUsersPerSec? 44. Why can DNS resolution skew traffic from Gatling injectors? 45. How do you troubleshoot errors that appear only in distributed Gatling runs? 46. How do you monitor injectors and the target during a distributed run? 47. Why is warm-up important in distributed performance tests? 48. How do you compare results between distributed Gatling test runs? 49. How can you optimize a Gatling simulation to reduce injector load? 50. How do you validate a distributed Gatling setup with a smoke test before full scale?

1. What is distributed performance testing?

Distributed performance testing means generating load from several machines at the same time against one system under test. Together they produce more traffic than a single machine could, or they send it from different network locations.

With Gatling, each machine runs its own injector (a JVM running your simulation). Every injector executes a slice of the total workload, and the results are combined afterwards into one report.

  • Needed when one machine hits its CPU, memory, network or port limit before the target does.
  • Useful for testing from multiple regions or networks.
  • Requires splitting users and test data so injectors do not overlap.
Take quiz
What is the main reason to split load across several injectors?
Gatling simulations cannot run on a single machine
The application under test must run on several servers
One machine cannot generate the target load reliably
Where does the traffic come from in a distributed Gatling test?
The application servers replaying their own logs
Several load generator machines running at the same time
One machine opening many browser tabs

2. What is Gatling?

Gatling is an open-source load testing tool where tests are written as code. You describe user behaviour in a DSL available in Java, Kotlin and Scala (and JavaScript/TypeScript in recent releases), and Gatling turns it into virtual users.

It is built on an asynchronous, non-blocking engine, so thousands of virtual users share a small number of threads instead of one thread each. It supports HTTP, WebSocket, SSE and JMS out of the box, and produces detailed HTML reports from every run.

Take quiz
How are Gatling tests defined?
As XML test plans edited by hand
Only through a drag-and-drop GUI
As code written in a DSL
What lets Gatling run many virtual users on few threads?
One OS thread dedicated to each user
Launching a headless browser per user
Asynchronous non-blocking I/O

3. What are the limits of a single load generator?

A single machine runs out of something before you reach very high load. The usual limits are CPU, memory, network bandwidth, file descriptors and ephemeral ports.

Resource What happens when it runs out
CPU Injector delays requests, so measured response times inflate.
Heap / GC Long garbage collection pauses create artificial latency spikes.
Network Bandwidth saturates, especially with large payloads or TLS.
Ephemeral ports New connections fail once the local port range is used up.
File descriptors Too many open files errors appear.

The dangerous part is that results look like server slowness, even though the generator is the bottleneck.

Take quiz
Which sign most strongly suggests the injector is overloaded?
Response times climb while server metrics stay low
The report cannot be generated
Every request returns HTTP 404
Which OS resource caps concurrent outgoing connections to one server IP and port?
The ephemeral port range
Disk inode count
Screen resolution of the host

4. What is a Gatling simulation?

A simulation is the top-level test definition. It is a class extending Simulation that holds the protocol configuration, one or more scenarios, and a setUp block that decides how many users are injected and how.

public class BasicSimulation extends Simulation {
  HttpProtocolBuilder httpProtocol = http.baseUrl("https://test.example.com");
  ScenarioBuilder scn = scenario("Browse")
      .exec(http("home").get("/"))
      .pause(1);
  {
    setUp(scn.injectOpen(rampUsers(100).during(60)))
        .protocols(httpProtocol);
  }
}

Anything you run, distributed or not, starts from a simulation class.

A project can hold several simulation classes, for example a smoke test and a soak test, and you choose which one to run at launch time with gatling.simulationClass or the -s option of the bundle script.

Take quiz
Where do you attach injection profiles to a scenario?
Inside the setUp block
In the HTTP protocol builder
In the feeder CSV header
Which base class does a Gatling test extend?
GatlingRunner
LoadTest
Simulation

5. What are injection profiles in Gatling?

An injection profile controls when and how fast virtual users start. You pass it to injectOpen or injectClosed in setUp.

Open model steps Closed model steps
atOnceUsers, rampUsers constantConcurrentUsers
constantUsersPerSec, rampUsersPerSec rampConcurrentUsers
nothingFor, stressPeakUsers incrementConcurrentUsers

Steps can be chained, for example a ramp, then a constant rate, then a pause.

A typical load test chains steps: a short ramp to warm up, a constant rate for the measurement window, then a ramp down. The profile is applied per scenario, so one simulation can drive a browsing scenario and a checkout scenario at different rates.

Take quiz
Which step injects users at a fixed arrival rate?
constantUsersPerSec
constantConcurrentUsers
nothingFor
What does nothingFor do in an injection profile?
Disables the scenario's checks
Pauses injection for a given duration
Deletes all running users

6. What is the difference between open and closed workload models?

An open model controls the arrival rate of users, regardless of how the system responds. A closed model controls the number of concurrent users, and a new user only starts when another finishes.

Open model Closed model
Users arrive at a set rate. Concurrency is capped.
Slow server means users pile up. Slow server means fewer new requests.
Models public websites and APIs. Models call centres and fixed-size pools.

Open models are usually safer for exposing real capacity limits, because the load does not back off when the server slows down.

Take quiz
What does an open workload model fix?
The number of CPU cores on the injector
The total test duration only
The arrival rate of new users
When the server slows down under a closed model, what happens?
More users pile up automatically
Fewer new requests are sent
Gatling stops the test

7. What are the main components of a distributed Gatling setup?

Every distributed setup has the same five parts, whether you build it by hand or use a platform.

flowchart LR
  C["Controller / CI job"] --> I1["Injector 1"]
  C --> I2["Injector 2"]
  C --> I3["Injector N"]
  I1 --> S["System under test"]
  I2 --> S
  I3 --> S
  I1 --> R["Results store"]
  I2 --> R
  I3 --> R
  R --> M["Merged report"]
  1. Controller: a CI job, script or Gatling Enterprise that starts the run.
  2. Injectors: machines, containers or pods running the simulation.
  3. System under test: the target, reachable from every injector.
  4. Results store: where each injector's log ends up.
  5. Report generation: merges the logs into one report.
Take quiz
Which component actually generates the virtual user traffic?
The results store
The injectors
The merged report
What role does the controller play?
Starts the injectors and coordinates the run
Stores the system under test's database
Replaces the simulation class

8. What is an injector in Gatling?

An injector is a load generator: a machine, VM, container or pod running a JVM that executes your simulation and sends requests to the target.

In a distributed test you run several injectors, each with its own share of users. Each injector writes its own results, so the load generators never need to talk to each other.

Because injectors are plain JVMs, they run anywhere Java does: bare metal, cloud VMs, containers or Kubernetes pods. The main requirement is that each one has network access to the target and enough CPU and memory for its share of users.

Take quiz
What is an injector?
A database that stores test results
A JVM process that runs the simulation and sends load
A proxy that records browser sessions
Do injectors in open-source Gatling coordinate with each other?
Yes, via a shared Gatling master node
Yes, through a built-in RMI cluster
No, each runs independently and writes its own log

9. How do you run a Gatling simulation from Maven?

Add the gatling-maven-plugin to your project and call its test goal. Use gatling.simulationClass to choose which simulation to run.

mvn gatling:test -Dgatling.simulationClass=com.example.BasicSimulation

Results land under target/gatling/, in a folder named after the simulation and the run time. You can pass your own properties with -D and read them in the simulation, which is how injectors receive their user counts.

In CI, add -Dgatling.noReports=true if you only need the log and want to generate the report later from merged data. Use the same command on every injector so runs stay reproducible.

Take quiz
Which Maven goal runs a Gatling simulation?
surefire:load
gatling:test
gatling:inject
Which property selects the simulation class in the Maven plugin?
gatling.injectorId
gatling.scenarioName
gatling.simulationClass

10. What is a feeder in Gatling?

A feeder injects external test data, such as usernames or product IDs, into each virtual user's session. It reads from CSV, JSON, a database or a custom iterator.

FeederBuilder<String> users = csv("users.csv").circular();
ScenarioBuilder scn = scenario("Login")
    .feed(users)
    .exec(http("login").post("/login")
        .formParam("user", "#{username}"));

The strategy matters: queue uses each record once, random and shuffle randomise order, and circular loops back to the start.

In a distributed run, each injector reads its own copy of the feeder. That makes data design important: either give each node a separate file, or accept that records may be reused.

Take quiz
Which feeder strategy uses each record only once and then fails when data runs out?
random
circular
queue
What does a feeder put into the virtual user's session?
Test data attributes from each record
The injection profile
The simulation.log file

11. What are checks in Gatling?

Checks validate a response and optionally extract values from it. A request fails if a check does not pass, and that failure is counted in the report.

http("get order").get("/orders/1")
  .check(status().is(200))
  .check(jsonPath("$.id").saveAs("orderId"))

Keep checks lean on injectors: heavy body parsing on huge responses costs CPU and can cause the load generator itself to become the bottleneck.

Checks run after every response, so an expensive check multiplies by your request rate. Prefer status() and a targeted jsonPath over scanning the whole body, and check only what the business flow depends on.

Take quiz
What happens when a Gatling check fails?
The injector shuts down
The feeder file is deleted
The request is marked as failed in the results
What does saveAs do in a check?
Writes the response to a CSV feeder
Stores the extracted value in the user's session
Saves the simulation to disk

12. What are assertions in Gatling?

Assertions are pass/fail conditions on the whole run, declared in setUp. If any assertion fails, Gatling exits with a non-zero code, so CI can fail the build.

setUp(scn.injectOpen(constantUsersPerSec(20).during(300)))
  .protocols(httpProtocol)
  .assertions(
    global().successfulRequests().percent().gt(99.0),
    global().responseTime().percentile(95.0).lt(800));

In a distributed run, assertions are only meaningful against the combined data, so decide which command evaluates them: the merge step, not each injector alone. A failed assertion makes Gatling return a non-zero exit code, which any CI tool treats as a failed step.

Typical metrics are successfulRequests().percent(), failedRequests().count(), responseTime().percentile(95.0) and meanRequestsPerSec(). You can scope them with global(), forAll() or details('request name') for one specific request.

Take quiz
What do assertions give you in a CI pipeline?
A pass/fail result via the exit code
A replacement for the HTML report
Automatic injector provisioning
Where are assertions declared?
In the setUp block
Inside the feeder
In logback.xml

13. What is the simulation.log file in Gatling?

simulation.log is the raw record of a run. Every request, with timing and status, is written to it, and the HTML report is generated from it afterwards.

Each injector produces its own log. That is what makes distributed testing with open-source Gatling workable: collect every injector's log, put them in one folder with unique file names, and generate a single combined report from them.

Because the report is only a view of the log, you can regenerate it later with different settings, or merge logs, without re-running the test. Keep the raw logs of important runs for the same reason.

Take quiz
What is the HTML report generated from?
The simulation.log data
The feeder CSV files
The Maven pom.xml
Why is simulation.log central to distributed testing?
Logs from all injectors can be merged into one report
It carries the user count to each injector
It restarts failed injectors

14. What is the difference between a scenario and a simulation?

A scenario is a sequence of actions one virtual user performs, such as login, browse and checkout. A simulation is the complete test: it wires scenarios to injection profiles, protocols and assertions.

Scenario Simulation
Describes user behaviour. Describes the whole test run.
Built with scenario() and exec(). Built with setUp().
Several can exist in one simulation. One class is run per execution.

Think of the simulation as the test plan and scenarios as the user journeys inside it. In a distributed setup every injector runs the same simulation, so each node executes all scenarios with its own share of users.

Take quiz
What does a scenario describe?
The cloud region of an injector
The steps one virtual user performs
The report folder name
What ties scenarios to injection profiles?
The scenario's pause calls
The CSV feeder
The simulation's setUp block

15. What key metrics should you watch in a distributed Gatling run?

Watch the metrics from both sides: the target and the injectors. A result is only trustworthy if the load generators were healthy.

Where Metrics
Gatling report Requests per second, error percentage, p50/p95/p99 response times, active users.
Injectors CPU, heap and GC pauses, network throughput, open connections.
System under test CPU, memory, DB connections, queue depth, server-side latency.

Always compare client-side and server-side response times. A large gap often means the injector, network or load balancer is adding delay.

Percentiles such as p95 and p99 say more than averages, since averages hide slow outliers. Also track the error percentage over time, not just the final total.

Take quiz
Why monitor injector CPU and GC during the test?
To measure the database index size
To decide the feeder strategy
To confirm the load generator itself was not the bottleneck
A big gap between client and server response times often suggests:
The feeder file is too small
Delay from the injector, network or load balancer
The report uses the wrong locale

16. What are the common ways to run Gatling in distributed mode?

Open-source Gatling has no built-in cluster mode, so teams pick an orchestration style. Each has a different trade-off between effort and convenience.

Approach How it works Trade-off
Manual / scripts Start the simulation on several VMs via SSH, then merge logs. Simple, but you own all coordination.
CI matrix jobs Parallel pipeline jobs each run one injector. Easy to reproduce, limited by runner size.
Containers / Kubernetes Pods or Indexed Jobs run injectors. Elastic, needs shared storage for logs.
Gatling Enterprise Platform provisions injectors and merges results. Least effort, commercial product.

Take quiz
Which approach provisions injectors and merges results for you?
Gatling Enterprise
Manual SSH scripts
A single local Maven run
What is the main drawback of the manual script approach?
It cannot run more than one user
You must build and maintain coordination yourself
It only works with Scala

17. What is Gatling Enterprise?

Gatling Enterprise is the commercial platform from the Gatling team. It runs the same simulations as the open-source tool, but adds orchestration on top.

  • Starts and stops injectors across one or more locations, including cloud and private infrastructure.
  • Splits the load across injectors for you.
  • Shows live metrics and keeps run history for comparison.
  • Integrates with CI/CD tools.

Exact features and plans change, so check the current product documentation before committing to a design.

Many teams use it when injector management, regional load and result sharing become the main cost of testing. Open-source Gatling remains fully usable for smaller setups.

Take quiz
What does Gatling Enterprise add to the open-source tool?
Orchestration, live dashboards and run history
A new scripting language
Replacement of the HTTP engine
Do your existing simulations need to be rewritten to run on Enterprise?
No, the same simulation code is packaged and run
Yes, they must be converted to XML
Yes, they must use a different DSL

18. How do you split load across multiple Gatling injectors?

Divide the total workload by the number of injectors and pass each injector its share. Read these values as system properties in the simulation.

int totalRps  = Integer.getInteger("totalRps", 500);
int injectors = Integer.getInteger("injectors", 1);
int perNode   = Math.max(1, totalRps / injectors);

setUp(scn.injectOpen(constantUsersPerSec(perNode).during(600)))
    .protocols(httpProtocol);

Run each node with the same -DtotalRps and -Dinjectors. Watch for integer rounding: 500 split over 3 nodes loses 2 RPS, so assign the remainder to one node if exactness matters.

Split the user count the same way when you use closed models: constantConcurrentUsers(total / injectors) per node. For ramp-ups, divide both the starting and ending rates. After the run, check that the merged report shows about the intended total rate, which confirms the split worked.

Take quiz
If 600 RPS is needed across 3 equal injectors, each should target:
1800 RPS
200 RPS
600 RPS
How does each injector learn its share of the load?
Through system properties read in the simulation
It discovers peers over multicast
From the simulation.log file

19. How do you merge Gatling results from multiple injectors?

Copy each injector's simulation.log into one folder, rename them so the names are unique, then run Gatling in reports-only mode.

mkdir results
cp node1/simulation.log results/simulation-node1.log
cp node2/simulation.log results/simulation-node2.log
./gatling.sh -ro results

Gatling reads every log file in that folder and builds a single report. With the Maven plugin, use -Dgatling.reportsOnly=results instead.

After merging, check that the report's total request count equals the sum across injectors. If the number is lower, a log was copied too early or one file overwrote another. Keep the original per-node logs so you can inspect a single injector when needed.

Take quiz
Which option generates a report from existing logs without running a test?
Dry-run mode (-dr)
Replay mode (-rp)
Reports-only mode (-ro)
Why rename each simulation.log before merging?
Gatling only reads files with .txt extension
To change the injection profile
So the files do not overwrite each other in one folder

20. Explain the execution flow of a distributed test with open-source Gatling?

The flow has four phases: prepare, start, collect, report. Gatling itself only handles the middle two on each node, so a script or pipeline does the rest.

sequenceDiagram
  participant CI as Controller
  participant N1 as Injector 1
  participant N2 as Injector 2
  participant ST as Results store
  CI->>N1: Deploy simulation + data slice
  CI->>N2: Deploy simulation + data slice
  CI->>N1: Start (-DtotalRps, -Dinjectors)
  CI->>N2: Start (-DtotalRps, -Dinjectors)
  N1->>N1: Run, write simulation.log
  N2->>N2: Run, write simulation.log
  N1->>ST: Upload log
  N2->>ST: Upload log
  CI->>ST: Download all logs
  CI->>CI: gatling.sh -ro folder
  1. Package the simulation and split the feeder data per injector.
  2. Start all injectors as close together in time as possible.
  3. Wait for every injector to finish, then collect the logs.
  4. Run reports-only mode over the merged folder.
Take quiz
What is the last step in the open-source distributed flow?
Re-run the test on one node
Delete every simulation.log
Generate one report from all collected logs
Who coordinates the start of injectors in open-source Gatling?
The system under test
An external script or CI pipeline
A built-in Gatling master

21. How do you split feeder data across injectors to avoid duplicates?

If every injector reads the same CSV, users on different machines may log in with the same account or reuse the same order ID. The fix is to give each injector its own slice of the data.

The simplest option is to pre-split the file, one per node, and pick it with a property:

int node = Integer.getInteger("nodeIndex", 0);
FeederBuilder<String> users = csv("users_" + node + ".csv").queue();

Split with a script such as split -n l/3 users.csv, or generate per-node ranges up front. For generated IDs, give each node a range (node 0 starts at 0, node 1 at 1,000,000) or include the node index in the value.

Take quiz
What problem occurs if all injectors share the same unique-user CSV?
Different machines may reuse the same account at once
The report shows no data
Gatling refuses to start
Which approach gives each injector distinct data?
A per-node file chosen with a nodeIndex property
One shared file and a random strategy
Deleting the feeder from the scenario

22. Which feeder strategy is better in distributed tests: queue or circular?

It depends on whether data must be unique. Use queue when each record can only be used once, such as one-time vouchers or unique registrations. Use circular when records can be reused, such as read-only logins.

Strategy Behaviour Distributed risk
queue Each record once, in order. Run fails when a node's slice runs out.
circular Loops back to the start. Same record used by several users at once.
random Random pick, repeats allowed. Collisions across nodes are likely.

With queue, size each node's slice for its full test duration, with a safety margin.

A hybrid is common: queue for write operations that need unique values, and circular for read-only reference data such as search terms.

Take quiz
A feeder holds one-time coupon codes. Which strategy fits?
queue
random
circular
What is the risk of queue in a distributed run?
It duplicates records across injectors
A node's data slice can run out mid-test
It loops forever

23. How do you handle session tokens and shared state across injectors?

You do not share them. Gatling virtual users keep state in their own session on one injector, and there is no shared memory across machines.

Two patterns work well. Have each virtual user authenticate itself at the start of its scenario and store the token with saveAs. If login is too expensive, create tokens before the test and distribute them through per-node feeder files.

  • Never rely on a global variable to pass data between injectors.
  • Avoid scenarios where one user's output is another user's input across nodes.
  • If a shared resource is unavoidable, create it before the run.
Take quiz
How do virtual users on different injectors share data in memory?
Via the simulation.log file
They do not, state is per user on one injector
Through a built-in distributed cache
If login is expensive, what is a sound alternative?
Pre-generate tokens and feed them per node
Hard-code one token for all users
Skip authentication in the test

24. How do you synchronize start times across Gatling injectors?

Open-source Gatling does not synchronize starts. You trigger every injector at nearly the same moment yourself, and that moment decides whether your ramp-up lines up.

  • Start all processes in parallel from one controller, for example SSH commands sent with & followed by wait.
  • Use parallel CI jobs, but remember runner start-up delays vary.
  • Prepare first (deploy, warm the JVM, check connectivity), then trigger the actual run.

A few seconds of skew rarely matters in a 30-minute test, but it distorts short spike tests. Gatling Enterprise starts all injectors of a run together, so you do not build this yourself.

Take quiz
When does start skew matter most?
In tests that last many hours
In short spike tests
Only when using feeders
What is a basic way to start injectors together?
Run them one after another in a loop
Start them from the system under test
Launch parallel SSH commands, then wait

25. Why does clock synchronization matter across Gatling injectors?

Every request in simulation.log carries a timestamp from the injector's clock. When logs from several machines are merged, the report places events on one shared timeline.

If clocks drift by seconds, the merged report shows ramps and spikes in the wrong place, and per-second throughput graphs look smeared. Response times themselves stay correct, since each is a duration measured on one machine.

Run NTP or chrony on every injector and check the offset before a long run.

Check offsets with chronyc tracking or ntpq -p on each injector before the run. Cloud VMs usually sync well by default, but laptops and long-idle machines often do not.

Take quiz
What does clock drift distort in a merged report?
The HTTP status codes
The timeline of throughput and active users
The size of the response body
Which service keeps injector clocks aligned?
NTP or chrony
DNS round robin
A feeder

26. Explain the internal working of Gatling's engine for handling many users?

Gatling does not create a thread per virtual user. A virtual user is a lightweight state machine that moves through the scenario, and its steps are driven by non-blocking I/O events (built on Netty).

  1. A user sends a request and immediately releases its thread.
  2. The network layer waits for the response without blocking.
  3. When the response arrives, the user's next step runs on any free thread.
  4. Timing and status are written to the results log.

Because waiting costs almost nothing, a handful of threads can serve many thousands of users. The CPU cost is then mostly parsing, checks, TLS and logging, which is why those are what to tune on an injector.

Netty's event loops handle sockets, and a small pool does the scenario work. If you give Gatling more cores, it scales almost linearly until networking or the garbage collector becomes the limit.

Take quiz
What does a Gatling virtual user do while waiting for a response?
Sleeps inside a browser process
Holds one OS thread until the response arrives
Releases its thread, since I/O is non-blocking
What mostly drives CPU use on an injector?
TLS, response parsing, checks and logging
Waiting for slow responses
Number of CSV rows

27. How do you detect an overloaded Gatling injector?

An overloaded injector produces slow numbers that look like server problems. Look for evidence on the injector, not just in the report.

  • CPU consistently above roughly 70-80%, or a long run queue.
  • GC logs showing frequent or long pauses.
  • Latency gap: client p95 is much higher than server-side p95.
  • Connect errors or timeouts while the server looks idle.

A practical test: halve the load per injector by adding another one. If latency drops at the same total load, the generator was the bottleneck.

Also watch network interface throughput: a 1 Gbit link carrying large responses saturates long before CPU does. When you find an overloaded node, discard the run rather than trying to correct the numbers afterwards.

Take quiz
Adding an injector at the same total load makes latency drop. What does this suggest?
The feeder was too small
The database index was fixed
The previous injectors were the bottleneck
Which injector-side figure is a warning sign?
Disk usage under 10%
A short ramp-up
CPU staying above about 80%

28. How do you size injectors for a target requests-per-second?

Measure the capacity of one injector with your real simulation, then divide. A rule of thumb is useless here, because payload size, TLS, checks and think time change the result a lot.

  1. Run one injector against a test target and raise RPS until CPU reaches about 70%.
  2. Record that RPS as the safe capacity per node.
  3. Compute injectors = ceil(targetRps / safeCapacity).
  4. Add one spare node for headroom and failures.

Example: if one node safely handles 1,500 RPS and the target is 6,000, you need 4 nodes, so plan 5.

Re-test the safe capacity whenever the simulation changes, for instance after adding bigger payloads or extra checks. The number is a property of the simulation, not of the machine alone.

Take quiz
A node safely handles 1,500 RPS and the target is 6,000 RPS. Minimum nodes?
6
2
4
Why measure capacity with your own simulation?
Payload, TLS and checks change per-node capacity
Capacity only depends on disk speed
Gatling has a fixed limit of 500 RPS

29. Why should you tune JVM heap and GC settings on Gatling injectors?

An injector is a JVM, and JVM pauses go straight into your measurements. A long garbage collection pause delays requests and responses, which shows up as a latency spike that never happened on the server.

Set a fixed heap so it does not resize mid-test, and make sure it is large enough for the number of active users and any stored response data.

# bundle
JAVA_OPTS="-Xms4G -Xmx4G" ./gatling.sh -s com.example.BasicSimulation

With the Maven plugin, pass the same flags through the plugin's jvmArgs setting. Enable GC logging for the first runs to confirm pauses stay short.

Avoid giving the injector more memory than the machine can spare: a heap larger than physical RAM leads to swapping, which is worse than any GC pause. Start with 2-4 GB and increase only if GC logs show pressure.

Take quiz
Why does a long GC pause hurt test results?
It merges simulation logs wrongly
It creates latency that did not occur on the server
It lowers the server's CPU use
Why set -Xms equal to -Xmx on an injector?
To disable garbage collection
To avoid heap resizing during the test
To raise the user count

30. How do you avoid port exhaustion on Gatling injectors?

Each outgoing TCP connection uses a local port. When many connections go to one server IP and port, you can exhaust the ephemeral range, and new connections fail.

  • Widen the range: net.ipv4.ip_local_port_range = 1024 65535.
  • Raise file descriptor limits with ulimit -n (for example 100000).
  • Reuse connections with HTTP keep-alive and, if suitable, shareConnections.
  • Spread load over more injectors, since the limit is per source IP.
  • Consider kernel options for TIME_WAIT handling, such as tcp_tw_reuse.

Symptoms are Cannot assign requested address or connect errors that start only after load grows.

Check the current state with ss -s and the configured range with sysctl net.ipv4.ip_local_port_range. Behind a NAT gateway, the gateway's own port limit can be the real ceiling, in which case more public IPs are needed.

Take quiz
Which error hints at ephemeral port exhaustion?
404 Not Found
Feeder is empty
Cannot assign requested address
Why does adding injectors help with port exhaustion?
It disables TLS
It enlarges the heap
The port limit applies per source IP address

31. When should you use shareConnections in Gatling?

By default each virtual user opens its own connections, which mimics separate browsers. shareConnections() makes all users share one connection pool instead.

HttpProtocolBuilder httpProtocol = http
    .baseUrl("https://api.example.com")
    .shareConnections();

Use it when you model server-to-server traffic, where a few long-lived connections serve many requests. It also helps when connection set-up and TLS handshakes would otherwise dominate injector CPU and ports.

Leave it off when you simulate individual end users, since real browsers do not share connections with each other.

If you enable it, also review maxConnectionsPerHost, since the shared pool then bounds your real concurrency. Test both settings with a smoke run to see which one reflects your production traffic better.

Take quiz
Which traffic pattern suits shareConnections best?
Thousands of independent browsers
Server-to-server calls reusing a few connections
One-off file downloads
What is the default connection behaviour of a Gatling virtual user?
Each user opens its own connections
All users share one pool
Connections are never reused

32. Why does coordinated omission matter in Gatling tests?

Coordinated omission happens when a slow response delays the next request, so the test sends fewer requests exactly when the system is struggling. The recorded numbers then look better than what real users would feel.

A closed model is prone to this: users wait for a response before starting again. An open model keeps injecting users at a fixed rate, so slowness shows up as growing response times and queues.

Model During a stall
Closed Fewer requests sent, latency understated.
Open Arrivals continue, latency and backlog grow.

For capacity and SLA testing of public-facing systems, prefer open injection profiles.

Gatling reports response time as the time from sending the request until the response completes. So with an open model, a stall appears honestly as rising times and active-user counts instead of being hidden by a reduced request rate.

Take quiz
Which model is more exposed to coordinated omission?
Neither, Gatling prevents it fully
Open workload model
Closed workload model
What does coordinated omission do to results?
Corrupts simulation.log files
Makes latency look better than users experience
Doubles the error count

33. When would you choose Gatling Enterprise over open-source Gatling?

Choose open-source when you have a small team, a few injectors and the time to script coordination. Choose Enterprise when orchestration effort and visibility cost more than the licence.

  • You need many injectors across regions without managing VMs.
  • Several teams share tests and need run history, access control and comparisons.
  • You want live dashboards instead of waiting for log merges.
  • You want load split and injectors started in sync by the platform.

The simulation code itself is the same either way, so you can start open-source and move later without rewriting tests.

Cost matters too: compare licence cost against the engineering time to build and maintain your own orchestration, result storage and dashboards.

Take quiz
Which situation favours Gatling Enterprise?
A test that needs no reports
Many teams, many regions, need for live dashboards
A single developer running a 10-user smoke test
Do you need to rewrite simulations to move to Enterprise?
Yes, completely
Yes, but only the assertions
No, the same code runs on both

34. What is the difference between Gatling and JMeter for distributed testing?

JMeter ships a controller/agent mode: one controller sends the plan to remote agents over RMI and collects results from them. Open-source Gatling has no such coordinator: injectors run independently and logs are merged afterwards.

Aspect JMeter Gatling (open-source)
Coordination Built-in controller and agents. External scripts or CI.
Results Streamed to the controller during the run. Per-injector logs merged afterwards.
Test definition GUI-built XML plans. Code in Java, Kotlin, Scala.
Threading Thread per virtual user. Async, event-driven.

Streaming results to a single controller can make that node a bottleneck in JMeter, while Gatling avoids it by keeping injectors independent.

Tool choice also depends on skills: teams comfortable with code and version control tend to prefer Gatling, while teams that favour GUI-driven plans lean towards JMeter.

Take quiz
How are results combined in open-source Gatling?
Each injector's log is merged after the run
Sent to the system under test
Streamed live to a built-in master
Which tool has a built-in controller/agent distributed mode?
Neither of them
Open-source Gatling
JMeter

35. How does Gatling Enterprise distribute a test across injectors?

You choose how many injectors and in which locations to use. The platform then provisions them, delivers your packaged simulation, divides the load profile among the injectors and starts them together.

sequenceDiagram
  participant U as Engineer / CI
  participant E as Enterprise platform
  participant I as Injectors (N)
  participant T as System under test
  U->>E: Start run (package, locations, counts)
  E->>I: Provision and deploy simulation
  E->>I: Start with split load profile
  I->>T: Generate load
  I-->>E: Stream live metrics
  E-->>U: Dashboard and final report

Metrics flow back to the platform in real time, so there is no manual log merge. Exact provisioning options depend on your plan and deployment, so verify in the current docs.

Because one platform both starts the injectors and aggregates their metrics, run time clocks and result merging are handled centrally, which removes two common sources of error from hand-built setups.

Take quiz
What does the platform do with the load profile?
Ignores it and uses defaults
Runs it on one injector only
Divides it among the injectors
How do results reach you on Enterprise?
You copy logs by hand
Injectors stream metrics back to the platform
They are emailed after the run

36. How do you run Gatling injectors in Docker?

Build an image from a JDK base that contains your simulation, either as a packaged Maven project or the Gatling bundle with your files. Each container is then one injector.

docker run --rm \
  -e JAVA_OPTS="-Xms2G -Xmx2G -DtotalRps=600 -Dinjectors=3 -DnodeIndex=1" \
  -v $(pwd)/results:/results \
  my-gatling-image

  • Mount a volume so simulation.log survives the container.
  • Set CPU and memory limits and size the heap below the container limit.
  • Raise nofile limits (--ulimit nofile=100000).
  • Use host networking only if you need to avoid NAT overhead.

Keep the image small and versioned, so every run uses an identical injector. Pin the base image and the Gatling version to avoid surprises between runs.

Take quiz
Why mount a volume in an injector container?
To speed up the HTTP engine
To share the JVM between containers
So simulation.log is kept after the container exits
What should the JVM heap be relative to the container memory limit?
Smaller than the limit
Equal to the host RAM
Unlimited

37. How do you run distributed Gatling on Kubernetes?

The cleanest pattern is an Indexed Job: completions and parallelism are both set to the injector count, and each pod receives a JOB_COMPLETION_INDEX. The pod uses that index as its node number for data slicing.

apiVersion: batch/v1
kind: Job
metadata: { name: gatling-run }
spec:
  completionMode: Indexed
  completions: 4
  parallelism: 4
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: injector
        image: my-gatling-image
        resources:
          requests: { cpu: "2", memory: 4Gi }

  1. Pods run the simulation using their index for data and load shares.
  2. Each pod uploads its log to shared storage such as S3 or a PVC.
  3. A final job downloads the logs and runs reports-only mode.

Request enough CPU per pod, and make sure all pods are scheduled before starting, otherwise the load ramps unevenly.

Take quiz
Which Kubernetes feature gives each injector pod its own number?
A LoadBalancer Service
A ConfigMap with random numbers
Indexed Job with JOB_COMPLETION_INDEX
Why wait until all pods are scheduled before the run starts?
Otherwise load ramps unevenly
Pods refuse to run alone
Gatling needs a quorum

38. How do you run distributed Gatling tests in a CI/CD pipeline?

Use a matrix of parallel jobs as injectors, upload each job's log as an artifact, then run a final job that merges the logs and applies pass/fail rules.

jobs:
  inject:
    strategy:
      matrix: { node: [0, 1, 2] }
    steps:
      - run: mvn gatling:test -DnodeIndex=${{ matrix.node }} -Dinjectors=3 -DtotalRps=600
      - uses: actions/upload-artifact@v4
        with:
          name: log-${{ matrix.node }}
          path: target/gatling/**/simulation.log
  report:
    needs: inject
    steps:
      - uses: actions/download-artifact@v4
      - run: ./merge-and-report.sh

Shared CI runners are small and noisy, so for serious load use self-hosted runners or trigger an external platform from the pipeline and wait for the result.

Store the load parameters (total RPS, injector count, duration) as pipeline variables, so the same pipeline can run a smoke test or a full test by changing inputs only.

Take quiz
What does the final pipeline job do?
Starts extra injectors
Merges all logs and checks pass/fail rules
Rebuilds the simulation
Why can shared CI runners be a poor injector choice?
They are small and have unpredictable performance
They block outbound HTTP
They cannot run Java

39. What happens when one injector fails in the middle of a Gatling test?

In open-source Gatling the other injectors keep running, because they do not depend on each other. The result is that total load drops by roughly 1/N from that moment, and the failed node's log may be missing or incomplete.

  • The merged report mixes full-load and reduced-load periods, so percentiles can mislead.
  • Throughput graphs show a sudden step down.
  • A partial log may not be readable at all.

Treat such a run as invalid unless you can prove the effect is small. Make your controller check every injector's exit status, and fail the pipeline if any node did not finish. Platforms like Gatling Enterprise report injector problems in the run view.

A good controller also stops the whole run when it detects a failed node, so you do not waste time and load on a test that is already invalid.

Take quiz
What happens to total load when one of 4 equal injectors dies?
It falls to about three quarters
It stays exactly the same
It doubles
How should you treat a run with a failed injector?
As invalid unless the impact is proven small
As a valid baseline
As a successful run if the report builds

40. How do you simulate geographically distributed users with Gatling?

Place injectors in the regions your users come from and give each a share of the load that matches your traffic mix. For example, 50% from Frankfurt, 30% from Virginia and 20% from Singapore.

  • With open-source, start VMs or pods in cloud regions yourself and pass each a regional weight property.
  • With Gatling Enterprise, you pick locations per run, including private locations behind a firewall.
  • Tag requests or use groups per region if you want regional breakdowns.

Remember that network latency now becomes part of response times, so compare regions against each other rather than against a single-region baseline.

Use one DNS name per region or a global load balancer if you want to test routing as well. Record the region in your report metadata so results from different locations are never mixed up.

Take quiz
How should regional load be shared?
Equally, whatever the real mix
All from one region
Following the real traffic mix of your users
What now influences measured response times in each region?
The Maven version
The feeder strategy
Network latency between injector and target

41. How do you use assertions as pass/fail gates across a distributed run?

Each injector only sees its own slice of traffic, so an assertion evaluated per node can pass while the combined result fails. Apply the gate to the merged data, then use the exit code in CI.

.assertions(
  global().successfulRequests().percent().gt(99.0),
  global().responseTime().percentile(95.0).lt(800),
  forAll().failedRequests().percent().lt(1.0))

Keep the same assertions in the simulation, and when running reports-only mode on the merged folder, check the exit status of that command. Choose thresholds from an agreed SLA, not from one lucky run.

Pick thresholds per request type where it matters: a login endpoint and a search endpoint rarely share the same latency target, so use details("login") for specific limits.

Take quiz
Why evaluate assertions on merged data?
A single injector sees only part of the traffic
Merged data removes slow requests
Assertions cannot run on a single node
How does a CI job learn that assertions failed?
The feeder becomes empty
A file named FAILED appears
The Gatling command exits with a non-zero code

42. When should you use throttle instead of injection profiles?

Injection profiles control how many users arrive. throttle caps requests per second regardless of how many users are active. Use it when the requirement is stated as a request rate.

setUp(scn.injectClosed(constantConcurrentUsers(200).during(600)))
  .throttle(reachRps(100).in(10), holdFor(5 * 60))
  .protocols(httpProtocol);

It is handy with closed models, where you know the concurrency but want a hard ceiling on throughput. In a distributed run each injector throttles only its own traffic, so divide the target RPS by the injector count.

Prefer injection profiles when the requirement is about users, and throttle when it is about throughput. Using both on the same scenario can confuse results, because the throttle can hide the effect of the injection profile.

Take quiz
What does throttle limit?
The number of CSV rows
The JVM heap
Requests per second
In a 4-injector run targeting 400 RPS, each injector's throttle should be:
400 RPS
100 RPS
1600 RPS

43. What is the difference between rampUsers and rampUsersPerSec?

rampUsers(n).during(t) injects a total of n users spread over the duration. rampUsersPerSec(a).to(b).during(t) changes the arrival rate from a to b users per second.

Step You control Example
rampUsers Total users over a period. rampUsers(600).during(60) means 10 users/s.
rampUsersPerSec Rate that rises or falls. rampUsersPerSec(1).to(50).during(120)

Use rampUsersPerSec to find the breaking point, because the rate keeps rising. In a distributed run, divide the rates (or user totals) by the injector count.

Both are open-model steps. With rampUsers, the arrival rate is flat across the period, whereas rampUsersPerSec produces a gradual increase, which better shows the point where response times start to climb.

Take quiz
rampUsers(600).during(60) injects users at about:
60 users per second
10 users per second
600 users per second
Which step lets you raise the arrival rate over time to find a limit?
rampUsersPerSec
atOnceUsers
nothingFor

44. Why can DNS resolution skew traffic from Gatling injectors?

If the target host name resolves to several IPs (DNS round robin or multiple load balancer nodes), every injector may resolve once and then send everything to the same address. The load is then uneven even though the test looks balanced.

  • Check how many addresses the name returns with dig.
  • Consider per-user name resolution in the HTTP protocol (perUserNameResolution), so users can resolve separately.
  • Or point injectors at an explicit load balancer address.
  • Verify the actual distribution on the server side.

Check the Gatling docs for your version, because DNS options differ between releases.

Also remember that corporate or cloud resolvers cache results, so injectors in different networks may see different answers for the same name.

Take quiz
What can happen when injectors resolve a multi-IP host name once?
All traffic goes to one address
Traffic is spread perfectly evenly
Requests are rejected by Gatling
How can you check which addresses a host name returns?
Read simulation.log
Open the feeder file
Run dig against the host name

45. How do you troubleshoot errors that appear only in distributed Gatling runs?

If a single injector is clean but the distributed run fails, the cause is usually shared resources, limits or data, not the scenario logic. Work through the likely suspects in order.

Symptom Likely cause
401 or 409 errors Duplicate accounts or IDs across injectors.
429 or 403 responses Rate limiting or a WAF blocking your source IPs.
Connect timeouts, resets Load balancer connection limits or NAT gateway exhaustion.
Uneven server load DNS resolved once, so traffic hits one node.
Odd latency spikes Injector CPU or GC problem on one node.

Compare each injector's own error rate: one bad node points to that machine, while all nodes failing points to the target or shared network path.

Keep one injector's raw log aside for each failed run. Comparing a single-node run with the distributed one, under the same per-node load, quickly separates injector problems from target problems.

Take quiz
A flood of 429 responses appears only at high distributed load. Likely cause?
The report folder is full
A syntax error in the simulation
Rate limiting on the target or in front of it
What do errors on only one injector suggest?
A bug in the database schema
A problem specific to that machine
A bad CSV header on all nodes

46. How do you monitor injectors and the target during a distributed run?

Monitor three layers: the test traffic, the injector hosts and the system under test. Without all three, you cannot say where a slowdown started.

  • Live test metrics: Gatling Enterprise dashboards, or in open-source a metrics writer such as Graphite where your version supports it.
  • Injector hosts: node_exporter or vmstat and top for CPU, memory, network.
  • Target: APM traces, DB metrics, queue depth and server logs.

Put all dashboards on one time axis and note the test start time, so you can line up a latency rise with a resource spike.

Alert on injector CPU during the run, so you can abort the test early when a load generator is saturated instead of finding out afterwards.

Take quiz
Why monitor injector hosts as well as the target?
Gatling cannot run without it
To increase the user count
To rule out the load generators as the bottleneck
What helps correlate a latency rise with a resource spike?
Only the final HTML report
Separate unlabelled graphs
Dashboards on one shared time axis

47. Why is warm-up important in distributed performance tests?

A cold system gives misleading early numbers. JVMs have not compiled hot code, caches are empty, connection pools are not filled and autoscaling has not reacted yet. This applies to the target, and to every injector JVM as well.

  • Ramp up gradually instead of using atOnceUsers for the full load.
  • Run a short low-load phase first to warm caches and connections.
  • Judge results on the steady-state period, not on the ramp.

In distributed runs, also warm each injector so all nodes start the real phase in a comparable state. Document how long the warm-up lasts, so repeated runs stay comparable.

Take quiz
Why avoid hitting a cold system with full load at once?
It disables assertions
It breaks the CSV feeder
Early results are distorted by cold caches and pools
Which period should you judge for performance results?
The steady-state period
Only the ramp phase
Only the first second

48. How do you compare results between distributed Gatling test runs?

Compare like with like: same simulation, same load profile, same injector count and sizes, same target environment. Otherwise a difference in numbers may come from the setup, not from the application.

  1. Name and archive each run's merged logs with build number and commit hash.
  2. Record the setup: injector count, instance types, regions, and target version.
  3. Compare p95/p99, throughput and error rate on the steady-state period.
  4. Fail the build if a key metric regresses beyond an agreed margin.

Gatling Enterprise keeps run history and offers side-by-side comparison. In open-source you can keep the HTML reports and extract numbers from them or from the logs.

Take quiz
What must stay constant when comparing two runs?
Load profile, injector setup and target environment
The name of the report folder only
The date of the run
What is a good practice for archiving logs?
Tag them with build number and commit hash
Keep only the HTML screenshot
Overwrite the previous run's logs

49. How can you optimize a Gatling simulation to reduce injector load?

The cheapest win is to remove work the injector does not need to do. Every check, regex and logged byte uses CPU that could be producing load.

  • Use only the checks you really need; avoid parsing big bodies with regex or full JSONPath.
  • Do not save response bodies you never use.
  • Use shareConnections for server-to-server tests to cut TLS handshakes.
  • Keep logging at WARN or ERROR level in logback.xml, with debug logging only while developing.
  • Avoid heavy session functions that build large strings per request.
  • Size the heap properly and add injectors instead of overloading one.

Measure again after each change, because the gain varies with payload size and request rate.

Remember that disabling useful checks makes the test less valid. The aim is to remove waste, not validation: keep any check that proves the response is actually correct.

Take quiz
Which change reduces CPU use on an injector?
Adding more regex checks
Removing unneeded body-parsing checks
Enabling debug logging
Which logging level suits a real load run?
DEBUG for every request
WARN or ERROR
TRACE

50. How do you validate a distributed Gatling setup with a smoke test before full scale?

Run a small, short test through the full distributed path first. The goal is to check the setup, not the application's capacity.

  1. Run at about 5% of target load for a few minutes, using every injector.
  2. Confirm each injector starts, reaches the target and writes its log.
  3. Check that data slices differ and no duplicate-data errors appear.
  4. Merge the logs and verify totals match the expected split.
  5. Compare injector clocks and check CPU and network headroom.

Fixing a missing firewall rule or a wrong feeder file at 5% load costs minutes. Finding it during a one-hour full-scale run costs the whole slot.

Take quiz
What is the main purpose of a distributed smoke test?
To replace the final full-scale run
To verify the setup works end to end
To find the maximum capacity
About what load level suits a smoke test?
Exactly the full target
150% of the target
A small fraction of the target, such as 5%
«
»
API

Comments & Discussions