The Grid is designed as a set of components that all fulfill a role in maintaining the Grid. It can seem quite complicated, but hopefully this document can help clear up any confusion.
The Key ComponentsThe main components of the Grid are:
While discussing the Grid, there are some other useful concepts to keep in mind:
There are two main communication mechanisms used within the Grid:
How do we pick which communication mechanism to use? After all, we could model the entire Grid in an event-based way, and it would work out just fine.
The answer is that if the action being performed is synchronous (eg. most WebDriver calls), or if missing the response would be problematic, the Grid uses a synchronous call. If, instead, we want to broadcast information to anyone who’s interested, or if missing the response doesn’t matter, then we prefer to use the event bus.
One interesting thing to note is that the async calls are more decoupled from their listeners than the synchronous calls are.
Start Up Sequence and Dependencies Between ComponentsAlthough the Grid is designed to allow components to start up in any order, conceptually the order in which components starts is:
You can picture the dependencies between components this way, where a “✅” indicates that there is a synchronous dependency between the components.
Event Bus Distributor Node Router Session Map Session Queue Event Bus X Distributor ✅ X ✅ ✅ Node ✅ X Router ✅ X ✅ Session Map X Session Queue ✅ X Node RegistrationThe process of registering a new Node to the Grid is lightweight.
GET
the /status
endpoint of the Node. It is from this information that the Grid is set up.The Distributor will use the same /status
endpoint to check the Node on a regular basis, but the Node should continue sending heart beat events even after started so that a Distributor without a persistent store of the Grid state can be restarted and will (eventually) be up to date and correct.
The Node Status is a JSON blob with the following fields:
Name Type Description availability string A string which is one ofup
, draining
, or down
. The important one is draining
, which indicates that no new sessions should be sent to the Node, and once the last session on it closes, the Node will exit or restart. externalUrl string The URI that the other components in the Grid should connect to. lastSessionCreated integer The epoch timestamp of when the last session was created on this Node. The Distributor will attempt to send new sessions to the Node that has been idle longest if all other things are equal. maxSessionCount integer Although a session count can be inferred by counting the number of available slots, this integer value is used to determine the maximum number of sessions that should be running simultaneously on the Node before it is considered “full”. nodeId string A UUID used to identify this instance of the Node. osInfo object An object with arch
, name
, and version
fields. This is used by the Grid UI and the GraphQL queries. slots array An array of Slot objects (described below) version string The version of the Node (for Selenium, this will match the Selenium version number)
It is recommended to put values in all fields.
The Slot ObjectThe Slot object represents a single slot within a Node. A “slot” is where a single session may be run. It is possible that a Node will have more slots than it can run concurrently. For example, a node may be able to run up 10 sessions, but they could be any combination of Chrome, Edge, or Firefox; in this case, the Node would indicate a “max session count” of 10, and then also say it has 10 slots for Chrome, 10 for Edge, and 10 for Firefox.
Name Type Description id string UUID to refer to the slot lastStarted string When the slot last had a session started, in ISO-8601 format stereotype object The minimal set of capabilities this slot will match against. A minimal example is{"browserName": "firefox"}
session object The Session object (see below) The Session Object
This represents a running session within a slot
Name Type Description capabilities object The actual capabilities provided by the session. Will match the return value from the new session command startTime string The start time of the session in ISO-8601 format stereotype object The minimal set of capabilities this slot will match against. A minimal example is{"browserName": "firefox"}
uri string The URI used by the Node to communicate with the session Support the Selenium Project
Learn more or view the full list of sponsors.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4