Max File Descriptors Setting

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



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 Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9161.38/IntelliJ -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

 * This sample is based on our official tutorials:
 * - [Gatling quickstart tutorial](
 * - [Gatling advanced tutorial](

class ComputerDatabaseSimulation : Simulation() {

    val httpProtocol =
            // Here is the root for all relative URLs

    // A scenario is a chain of requests and pauses
    val scn =
        scenario("Scenario Name")
                    .queryParam("num1", Random.nextInt())
                    .queryParam("num2", Random.nextInt())

    init {
            val osMBean = ManagementFactory.getOperatingSystemMXBean() as UnixOperatingSystemMXBean
            println("opendfs: ${osMBean.openFileDescriptorCount}")
            println("maxfds:  ${osMBean.maxFileDescriptorCount}")

ComputerDatabaseSimulation Console output:

opendfs: 169
maxfds:  10240
Simulation computerdatabase.ComputerDatabaseSimulation started...

OS tuning is in the documentation and an absolute must:

The top file descriptor limit on GNU/Linux is ~65K. Run only Gatling and associated tools on your load injector. The Gatling Enterprise boxes will be pre-tuned. Whoever at Gatling Corp suggested the tuning knows their stuff because I don’t even understand some of the settings and must have a system administrator background. Explanations may be nice. TODO: Provide kernel tuning explanations and submit a PR.

There is nothing on filesystem paramaters, but distros use different filesystems. Ext4 was the most common Linux filesystem, but some distros will be using btrfs now.

Maybe (and feel free to rebuke me) increase inode cache, the readahead buffer size, enable delayed allocation and optimise the journaling mode.

1 Like

these are my settings

> ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8176
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       2666
-n: file descriptors                64000
> sudo cat /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  <plist version="1.0">

And about last lines of your message- I don’t know how to tune them(inode cache etc.) but I will check. I made some progress by tuning client(gatling) and server(my application) by changing java args(-XX:-MaxFDLimit ) but the only change is my error, now I get this

At least, something new to investigate :laughing:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.