I am trying to make a load test on an API with a lot of concurrent requests. you can see the test below, However, it had troubles due to max file descriptors by OS, I increased that level and passed that problem. I verified that by running CheckOpenFS with -XX:-MaxFDLimit, However, maven does not recognize it with MAVEN_OPTS or any other setting and it does not recognize JVM flag or maybe it maven recognizes it but Gatling plugin somehow omits.
Can you help me to run help running gatling:test running with OS default max descriptors
CheckOpenFS:
import com.sun.management.UnixOperatingSystemMXBean;
import java.lang.management.ManagementFactory;
public class CheckOpenFS {
public static void main(String[] args) {
final UnixOperatingSystemMXBean osMBean =
(UnixOperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
System.out.println("opendfs: " + osMBean.getOpenFileDescriptorCount());
System.out.println("maxfds: " + osMBean.getMaxFileDescriptorCount());
}
}
CheckOpenFS Console output:
/Users/mustafayildirim/.sdkman/candidates/java/21.ea.28-open/bin/java -XX:-MaxFDLimit -javaagent:/Users/mustafayildirim/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=61416:/Users/mustafayildirim/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/mustafayildirim/IdeaProjects/untitled/out/production/hackerearth CheckOpenFS
opendfs: 8
maxfds: 64000
Process finished with exit code 0
Maven Gatling test class
package computerdatabase
import io.gatling.javaapi.core.*
import io.gatling.javaapi.http.*
import io.gatling.javaapi.core.CoreDsl.*
import io.gatling.javaapi.http.HttpDsl.*
import java.time.Duration
import java.util.concurrent.ThreadLocalRandom
import kotlin.random.Random
import com.sun.management.UnixOperatingSystemMXBean
import java.lang.management.ManagementFactory
/**
* This sample is based on our official tutorials:
*
* - [Gatling quickstart tutorial](https://gatling.io/docs/gatling/tutorials/quickstart)
* - [Gatling advanced tutorial](https://gatling.io/docs/gatling/tutorials/advanced)
*/
class ComputerDatabaseSimulation : Simulation() {
val httpProtocol =
http
// Here is the root for all relative URLs
.baseUrl("http://localhost:9595")
.enableHttp2()
// A scenario is a chain of requests and pauses
val scn =
scenario("Scenario Name")
.exec(
http("request_1").get("/multiply")
.queryParam("num1", Random.nextInt())
.queryParam("num2", Random.nextInt())
)
init {
val osMBean = ManagementFactory.getOperatingSystemMXBean() as UnixOperatingSystemMXBean
println("opendfs: ${osMBean.openFileDescriptorCount}")
println("maxfds: ${osMBean.maxFileDescriptorCount}")
setUp(
scn.injectOpen(
stressPeakUsers(1).during(30)
).protocols(httpProtocol)
)
}
}
ComputerDatabaseSimulation Console output:
opendfs: 169
maxfds: 10240
Simulation computerdatabase.ComputerDatabaseSimulation started...