How to maintain a persistent HTTP connection per user with closed injection model


I’m trying to simulate 5 nodes that will contact my API. And all 5 of these nodes will maintain a long lived TCP connection to send their HTTP (actually HTTPS) requests, in order to avoid the overhead of doing a new TCP and TLS handshake on each request.

Here is Gatling code I’m currently using:

package projectabc

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class BasicSimulation extends Simulation {

val feeder = csv(“search.csv”).random

val httpProtocol = http

val scn = scenario(“BasicSimulation”)

constantConcurrentUsers(5) during (5 seconds))

Unfortunately, it doesn’t work as intended: the keep-alive header is sent but a new TCP connection is opened on each HTTP request. I’m using Gatling 3.1.2. Is there anything wrong with my config?

Thank you for your help.

I guess I misunderstood how Gatling work with close injection model. each virtual user will send only one GET request before getting it gets terminated. Then constantConcurrentUsers makes sure that the number of active virtual users stay constant (by creating new ones as old ones are terminated).