SeleniumHQ / SeleniumHQ/docker-selenium

[🐛 Bug]: maxSessions config value larger then CPU count is ignored

Open
#2,610 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triaging
Dominant language
Go
Stars
8.7k
Forks
2.5k
Avg merge
10h 16m
Merged PRs (30d)
20

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied docker run commands and config.toml, focusing on the node settings override-max-sessions and max-sessions. Compare the configured value and the node status response with the log line showing the capability mapped four times; done means the reported maxSessions matches the configured value of 10.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.