Skip to content

[πŸ› Bug]: maxSessions config value larger then CPU count is ignoredΒ #2610

@Zlaman

Description

@Zlaman

What happened?

My VM has 4 CPU's. I am starting selenium/hub and selenium/node-docker with below commands.
config.toml has override-max-sessions = true and max-sessions = 10
As per the logs from selenium/node-docker (see them below) - Max sessions set to 10, but another line is Mapping Capabilities {browserName: chrome, platformName: linux, se:downloadsEnabled: true} to docker image selenium/standalone-chrome:latest **4 times**
It results in "maxSessions": 4 while expected is 10 as per config.toml

curl localhost:4444/wd/hub/status

{
  "value": {
    "ready": true,
    "message": "Selenium Grid ready.",
    "nodes": [
      {
        "id": "0f578f41-ac9c-484a-b06d-6777a8384a4a",
        "uri": "http:\u002f\u002f172.18.0.3:5555",
        "maxSessions": 4,
        "sessionTimeout": 300000,
        "osInfo": {
          "arch": "amd64",
          "name": "Linux",
          "version": "5.15.167.4-microsoft-standard-WSL2"
        },
        "heartbeatPeriod": 60000,
        "availability": "UP",
        "version": "4.27.0 (revision d6e718d)",
        "slots": [
          {
            "id": {
              "hostId": "0f578f41-ac9c-484a-b06d-6777a8384a4a",
              "id": "9ecdd10f-ac80-4a06-b1c2-cc1ced9232d4"
            },
            "lastStarted": "1970-01-01T00:00:00Z",
            "session": null,
            "stereotype": {
              "browserName": "chrome",
              "platformName": "linux",
              "se:downloadsEnabled": true
            }
          },
          {
            "id": {
              "hostId": "0f578f41-ac9c-484a-b06d-6777a8384a4a",
              "id": "a58f5da3-83ce-422d-b390-e4bd63203cc2"
            },
            "lastStarted": "1970-01-01T00:00:00Z",
            "session": null,
            "stereotype": {
              "browserName": "chrome",
              "platformName": "linux",
              "se:downloadsEnabled": true
            }
          },
          {
            "id": {
              "hostId": "0f578f41-ac9c-484a-b06d-6777a8384a4a",
              "id": "592f3a21-3c70-4258-b4eb-13a92125a6dd"
            },
            "lastStarted": "1970-01-01T00:00:00Z",
            "session": null,
            "stereotype": {
              "browserName": "chrome",
              "platformName": "linux",
              "se:downloadsEnabled": true
            }
          },
          {
            "id": {
              "hostId": "0f578f41-ac9c-484a-b06d-6777a8384a4a",
              "id": "9a7759c7-0d04-4b0f-a420-5f08d2f7d58d"
            },
            "lastStarted": "1970-01-01T00:00:00Z",
            "session": null,
            "stereotype": {
              "browserName": "chrome",
              "platformName": "linux",
              "se:downloadsEnabled": true
            }
          }
        ]
      }
    ]
  }
}

I have also tried to start selenium-node-docker with extra environment variables
-e SE_NODE_MAX_SESSIONS=10
-e SE_NODE_OVERRIDE_MAX_SESSIONS=true
but it does not help as well.

Command used to start Selenium Grid with Docker (or Kubernetes)

docker network create grid
docker run -d -p 4442-4444:4442-4444 --network grid --name selenium-hub selenium/hub:latest
docker run -d --network grid --name selenium-node-docker \
    -e SE_EVENT_BUS_HOST=selenium-hub \
    -e SE_EVENT_BUS_PUBLISH_PORT=4442 \
    -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
    -e SE_BROWSER_ARGS_DISABLE_DSHM=--disable-dev-shm-usage \
    -e SE_START_VNC=false \
    -e SE_START_NO_VNC=false \
    -e SE_ENABLE_TRACING=false \
    -e SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml \
    -v /home/user/selenium/config.toml:/opt/selenium/docker.toml:ro \
    -v /home/user/selenium/assets:/opt/selenium/assets \
    -v /home/user/selenium/downloads:/home/seluser/Downloads \
    -v /var/run/docker.sock:/var/run/docker.sock \
    selenium/node-docker:latest

# config.toml
[docker]
configs = [
    "selenium/standalone-chrome:latest", '{"browserName": "chrome"}'
]
host-config-keys = ["Binds"]
url = "http://127.0.0.1:2375"
video-image = "selenium/video:latest"

[node]
detect-drivers = false
enable-managed-downloads = true
override-max-sessions = true
max-sessions = 10

Relevant log output

selenium/node-docker
Starting Selenium Grid Node Docker...
2025-01-23 04:21:37,253 INFO success: socat entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2025-01-23 04:21:37,253 INFO success: selenium-grid-docker entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Appending Selenium option: --log-level INFO
Appending Selenium option: --http-logs false
Appending Selenium option: --structured-logs false
Appending Selenium option: --tracing false
Tracing is disabled
04:21:37.483 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
04:21:37.485 INFO [LoggingOptions.getTracer] - Using null tracer
04:21:37.507 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-hub:4442 and tcp://selenium-hub:4443
04:21:37.528 INFO [UnboundZmqEventBus.<init>] - Sockets created
04:21:38.529 INFO [UnboundZmqEventBus.<init>] - Event bus ready
04:21:38.578 INFO [NodeServer.createHandlers] - Reporting self as: http://172.18.0.3:5555
04:21:38.580 INFO [LoggingOptions.getTracer] - Using null tracer
04:21:38.592 INFO [NodeOptions.getSessionFactories] - Detected 4 available processors
04:21:38.593 WARN [NodeOptions.getSessionFactories] - Overriding max recommended number of 4 concurrent sessions. Session stability and reliability might suffer!
04:21:38.594 WARN [NodeOptions.getSessionFactories] - One browser session is recommended per available processor. Safari is always limited to 1 session per host.
04:21:38.594 WARN [NodeOptions.getSessionFactories] - Overriding this value for Internet Explorer is not recommended. Issues related to parallel testing with Internet Explored won't be accepted.
04:21:38.594 WARN [NodeOptions.getSessionFactories] - Double check if enabling 'override-max-sessions' is really needed
04:21:38.594 WARN [NodeOptions.getSessionFactories] - Max sessions set to 10
04:21:38.814 INFO [V141Docker.isContainerPresent] - Checking if container is present: e67e0b9cbd42
04:21:38.923 INFO [Docker.getImage] - Obtaining image: selenium/standalone-chrome:latest
04:21:38.926 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/standalone-chrome', tag='latest', digest='null'}
04:21:38.935 INFO [Docker.getImage] - Obtaining image: selenium/video:latest
04:21:38.935 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/video', tag='latest', digest='null'}
04:21:38.938 INFO [Docker.getImage] - Obtaining image: selenium/video:latest
04:21:38.938 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/video', tag='latest', digest='null'}
04:21:38.942 INFO [Docker.getImage] - Obtaining image: selenium/standalone-chrome:latest
04:21:38.942 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/standalone-chrome', tag='latest', digest='null'}
04:21:38.947 INFO [DockerOptions.lambda$getDockerSessionFactories$2] - Mapping Capabilities {browserName: chrome, platformName: linux, se:downloadsEnabled: true} to docker image selenium/standalone-chrome:latest 4 times
04:21:38.954 INFO [Node.<init>] - Binding additional locator mechanisms: relative
04:21:39.025 INFO [NodeServer$2.start] - Starting registration process for Node http://172.18.0.3:5555
04:21:39.026 INFO [NodeServer.execute] - Started Selenium node 4.27.0 (revision d6e718d): http://172.18.0.3:5555
04:21:39.031 INFO [NodeServer$2.lambda$start$1] - Sending registration event...
04:21:39.193 INFO [NodeServer.lambda$createHandlers$2] - Node has been added

Operating System

Ubuntu

Docker Selenium version (image tag)

selenium/hub:4.28.0-20250120 selenium/node-docker:4.28.0-20250120

Selenium Grid chart version (chart version)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions