skip to Main Content

We are trying to process many pages through Selenium at the same time. We can get up to 32 sessions, but as soon as we try to increase the session count further, all sessions start becoming janky, they are error prone and crash. Also, we get many errors that the sesssion cannot be started (error log at the bottom)

I’ve tried more then 5 versions of selenium (between 102 and latest 114) with the appropriate chrome driver and chrome version, but sooner or later the whole thing ends up with the errors above. Chrome is always crashing. I’ve also tried running in hub – node configuration, or standalone.

Why is chrome crashing? I am certain that memory is not a problem because I’ve also tried increasing jvm heapsize adding "-Xms64g -Xmx80g" in the command line above, but it didn;t help. Following selenium’s requirements I have installed and use oracle jdk (not jre) but still no help or whatsoever. What can I do to run multiple sessions (more then 32 i.e.)?

OS:
Ubuntu 22.04.2 LTS, running on a 32-Core Ryzen™ 9 and 128GB RAM.

java:
java version "20.0.1" 2023-04-18
Java(TM) SE Runtime Environment (build 20.0.1+9-29)
Java HotSpot(TM) 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)

Google Chrome 114.0.5735.133

command to launch selenium:

xvfb-run -a java -Dwebdriver.chrome.driver="/home/forge/domain/storage/selenium/chromedriver-114.0.5735.16" -jar "/home/forge/domain/storage/selenium/selenium-server-4.10.0.jar" standalone --override-max-sessions true --max-sessions 60 --port 4646 --allow-cors true

error log:

10:39:23.636 WARN [SeleniumSpanExporter$1.lambda$export$1] - Unable to create session: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: 
Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) 
Host info: host: 'domain', ip: '127.0.0.1'
Build info: version: '4.10.0', revision: 'c14d967899'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-75-generic', java.version: '20.0.1'
Driver info: driver.version: unknown
Build info: version: '4.10.0', revision: 'c14d967899'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-75-generic', java.version: '20.0.1'
Driver info: driver.version: unknown
10:39:23.636 WARN [SeleniumSpanExporter$1.lambda$export$1] - org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. 
Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) 
Host info: host: 'domain', ip: '127.0.0.1'
Build info: version: '4.10.0', revision: 'c14d967899'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-75-generic', java.version: '20.0.1'
Driver info: driver.version: unknown
Build info: version: '4.10.0', revision: 'c14d967899'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-75-generic', java.version: '20.0.1'
Driver info: driver.version: unknown
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:210)
    at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:69)
    at org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:147)
    at org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:467)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:643)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:560)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:814)
    at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:773)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1623)

mem stats
Mem: 131576260 15530844 76271352 82296 39774064 114669600
Swap: 5237752 0 5237752

I am creating the session like
RemoteWebDriver::create($host, $capabilities,3600000,3600000);

            '--remote-allow-origins=*',
            '--window-size=1920,1080',
            '--enable-experimental-extension-apis',
            '--disable-infobars',
            '--disable-notifications',
            '--disable-device-discovery-notifications',
            '--disable-gpu',
            '--allow-outdated-plugins',
            '--disable-web-security',
            '--allow-running-insecure-content',
            '--allow-file-access-from-log_files',
            '--audio-output-channels=0',
            '--ignore-certificate-error',
            '--disable-dev-shm-usage',
            '--disable-browser-side-navigation',
            '--dns-prefetch-disable',
            '--disable-geolocation',
            '--disable-search-geolocation-disclosure',
            '--enable-strict-powerful-feature-restrictions',
            '--disable-translate',
            '--disable-sync',
            '--mute-audio',
            '--lang=en-US',
            '--use-fake-ui-for-media-stream',
            '--use-fake-device-for-media-stream',
            '--allow-file-access-from-files',
            '--reduce-security-for-testing',
            '--allow-insecure-localhost',
            '--allow-legacy-extension-manifests',
            '--allow-loopback-in-peer-connection',
            '--allow-outdated-plugins',
            '--allow-unsecure-dlls',
            '--alsa-mute-device-name',
            '--also-emit-success-logs',
            '--alsa-mute-element-name',
            '--no-first-run',
            '--disable-default-apps',
            '--disable-extensions-http-throttling',
            '--disable-blink-features=AutomationControlled',

2

Answers


  1. Looking at your logs you seem to be using Selenium Grid functionality, did you read the documentation yet? Are you taking their recommendations into account with your design? As this might be a CPU limitation as opposed to a memory limitation.

    By default, the maximum amount of concurrent sessions a Node supports
    is limited by the number of CPUs available. For example, if the Node
    machine has 8CPUs, it can run up to 8 concurrent browser sessions
    (with the exception of Safari, which is always one). Additionally, it
    is expected that each browser session should use around 1GB RAM.

    Note that the default values (1CPU/1GB RAM per browser) are a
    recommendation and they could not apply to your context. It is
    recommended to use them as a reference, but measuring performance
    continuously will help to determine the ideal values for your
    environment.

    Source

    Taking the above documentation into account when you state:

    We can get up to 32 sessions, but as soon as we try to increase the
    session count further, all sessions start becoming janky

    And taking your CPU information provided:

    running on a 32-Core Ryzen™ 9

    Things seem to be clearing up.

    Login or Signup to reply.
  2. @BernardV
    The manual indicates the way how to override the number of sessions, by using those two parameters, and states that it is "not recommended" not that it is forbidden.

    "--override-max-sessions
          The # of available processors is the recommended max sessions value (1 
          browser session per processor). **Setting this flag to true allows the 
          recommended max value to be overwritten**. Session stability and 
          reliability might suffer as the host could run out of resources.
          Default: false
    --max-sessions
          Maximum number of concurrent sessions. Default value is the number of 
          available processors."
    

    I’ve tried this, because on other system it used to run perfectly fine like that. Your answer doesn;t bring any light on chrome crash btw, which also occurs even when running with (cpu count) sessions. Thx for your time, but really, I would appreciate some answers from users that have experienced this condition.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search