SeGrid Router enables auto scaling selenoid grid by managing launch and termination of cloud instances automatically based on demand. This include self installation of ggr and selenoid without any manual steps needed.

1. Getting started

You can chose to either launch a pre-configured machine from AWS marketplace, OR install manually on a pre-launched ubuntu instance.

  • While launching instance, you MUST chose an IAM profile which allows to launch/ terminate/ start/ stop/ describe instances. This is required as SeGrid router process will manage these instances automatically at runtime. Use following policy JSON to create a new policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:*"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:GetRole",
                "iam:PassRole"
            ],
            "Resource": "*"
        }
    ]
}
  • Security groups chosen should allow access on following ports-

    • 8080 - SeGrid Router Dashboard

    • 8081 - Selenoid UI when running in standalone mode

    • 8082 - Ggr status port

    • 8083 - Selenoid UI when running in load balancing mode

    • 4444 - Selenoid hub port

    • 4445 - Ggr port

1.1. Install from AWS marketplace

Head over to product page on aws marketplace and launch an EC2 instance.

1.2. Manual Installation

Launch latest stable ubuntu instance and run following commands to setup:

curl -fsSL https://raw.githubusercontent.com/segrid/sgr/main/install.sh -o install.sh
export SEGRID_VERSION=latest
export CLOUD_PROVIDER=aws           #change to azure for Azure cloud
sudo -E /bin/bash ./install.sh

2. Using SeGrid Router (a.k.a. sgr)

Once installation is complete, application will be accessible at http://<private-ip>:8080/segrid/. URL to be used with webdriver is also displayed on dashboard.

Sgr can be used in following two modes, Standalone (default when launched for the first time) and Load Balancer Mode.

2.1. Standalone Mode

In standalone mode, everything is automatically setup on main router instance itself. All sessions are created on router instance. This is basic and default.

2.2. Load Balancer Mode

This mode can be turned on by using button on dashboard header. In load balancer mode, router will manage additional cloud instance based on configuration and demand at runtime.

2.2.1. Configurations

Configuration Values Default Additional Info

InstanceType

Type of cloud instance to launch

same as initial instance launched

If you are changing, use an instance that has CPU:Memory in 1:2 ratio, e.g. 4cpu, 8gb instance

Scaling Mode

MANUAL, AUTO

MANUAL

MANUAL - instances should be pre-launched/ started before triggering test execution. When running in MANUAL mode, session creation fails immediately if router is out of capacity to accept new connections.

AUTO - automatically start/ stop/ launch/ terminate instances

Init Script

bash statement that will be executed, every time a new instance is launched

This can be potentially used to pre-configure instances, as such mounting an nfs drive, and then using folders on it to configure selenium logs and video locations

Min Free Sessions

Idle capacity always available to accept new session requests

0

This is used only when Scaling Mode is set to AUTO, and router is running in load balancer mode. New instances are launching when free capacity of the grid falls below this value.

Security Groups

Cloud security group to be assigned to instance on launch. Multiple groups can be added.

Same as main router instance

It is extremely important to ensure that correct group is provided, else instances will not be able to communicate with each other.

2.2.2. Accessing Video/ Logs

When enabled, video and selenium session logs can be accessed via http://<private-ip>:8080/segrid/video/<sessionId>; and http://<private-ip>:8080/segrid/logs/<sessionId>; respectively.

2.2.3. Using with Playwright

Premium

Playwright allows using selenium grid as remote server to launch sessions. See https://playwright.dev/docs/selenium-grid for additional information. In order to use sgr with playwright, set following environment variable before running your test scripts; SELENIUM_REMOTE_URL=http://<private-ip>:8080/segrid/hub

It is important that your tests should be running in same VPC as of sgr instance as playwright connectivity is enabled via direct connection to ports on sgr instance.

2.2.4. Screenshots

Premium

Sgr will provide full page screenshots by default irrespective of browser type. Currently, it is not possible to turn off this feature. Please open an issue if you would like to have configuration to turn this off.

2.3. Pricing

Sgr will always have two editions available for use:

Edition Pricing Use Case Additional Info

Community

$0

Easy and convenient one step selenium grid setup

Premium

$1 per parallel session

Auto scaling across any number of machines, additional premium features.

There are no hard licensing requirements or obligations to pay in order to use premium features. It will be always voluntary to pay to support upkeep of the project regularly. You can choose from monthly, annual or your own price to contribute.

2.4. Browser Images

We maintain a copy of browser images in aws ECR repository, as using at runtime from docker hub causes issues with rate limits enforced by docker. Following repositories are available for public usage:

These images are updated once every day based using automated github actions available at https://github.com/segrid/sgr/actions/workflows/images.yaml.

2.5. Reporting Issues/ Feature Requests