Selenium Grid 4 Components: Master Setup & Modern Test Architecture

Date:

Share post:

Are you still struggling with outdated Selenium Grid 3 architecture while your competitors leverage Selenium Grid 4’s revolutionary distributed components for lightning-fast parallel testing? The testing landscape has fundamentally changed, and QA professionals who don’t adapt to Grid 4’s modern architecture risk falling behind in an increasingly competitive market.

Selenium Grid 4 represents a complete ground-up rewrite designed specifically for containerization, cloud-distributed scalability, and modern computing environments. Unlike Grid 3’s simple hub-node setup, Grid 4 introduces six sophisticated components that work together to deliver unprecedented performance, reliability, and scalability for test automation teams.

The market impact is undeniable โ€” organizations using Selenium Grid 4 report up to 85% faster test execution compared to Grid 3, while achieving 50% cost savings through optimized resource utilization. With the global test automation market projected to reach $52.7 billion by 2027, mastering Grid 4’s architecture is essential for staying competitive.


Revolutionary Architecture: From Hub-Node to Distributed Components

The Grid 4 Transformation

Selenium Grid 4 fundamentally reimagines test automation infrastructure by breaking the monolithic hub into specialized, scalable components. This microservice-based architecture enables better fault tolerance, horizontal scaling, and cloud-native deployment strategies that modern QA teams demand.

ComponentPurposeKey BenefitPerformance Impact
RouterEntry point for all requestsLoad balancing & request routingEliminates bottlenecks
DistributorNode management & session allocationIntelligent resource distribution40% better resource utilization
Session MapSession-to-node relationship trackingFast request routingReduced latency
New Session QueueRequest queuing with FIFO orderingControlled session creationPrevents overloading
NodeTest execution environmentBrowser instance managementOptimized for containers
Event BusInter-component communicationAsynchronous messagingEliminates expensive HTTP calls

Core Components Deep Dive

1. Router – The Intelligent Traffic Controller

The Router serves as Grid 4’s central nervous system, receiving all external requests and intelligently forwarding them to appropriate components. Unlike Grid 3’s direct hub communication, the Router implements sophisticated load balancing to prevent component overloading.

Key capabilities:

  • New session routingย to the New Session Queue
  • Existing session routingย via Session Map queries
  • Load balancingย across Grid components
  • Request optimizationย without component overloading

2. Distributor – The Resource Orchestrator

The Distributor revolutionizes node management by maintaining real-time awareness of all nodes and their capabilities through the GridModel. This component handles two critical responsibilities that ensure optimal resource utilization.

Core functions:

  • Node registration managementย via Event Bus communication
  • HTTP health verificationย for node availability
  • Session request processingย from New Session Queue
  • Session-to-node allocationย based on capabilities matching

3. Session Map – The Relationship Database

The Session Map acts as a high-performance data store maintaining the crucial relationship between session IDs and their corresponding nodes. This enables the Router to instantly locate the correct node for ongoing session requests.

Benefits:

  • Instant session-to-node lookup
  • Reduced routing latency
  • Simplified request forwarding
  • Enhanced session tracking

4. New Session Queue – The Request Buffer

The New Session Queue implements FIFO ordering with configurable timeout parameters, preventing Grid overload during high-demand periods. This component ensures controlled session creation and efficient resource allocation.

Advanced features:

  • Configurable request timeout handling
  • Automatic timeout detection and cleanup
  • Request retry interval management
  • Load-balanced session distribution

5. Node – The Execution Engine

Grid 4 Nodes are significantly enhanced compared to Grid 3, with automatic browser driver detection, CPU-based slot allocation, and native Docker container support.

Modern capabilities:

  • Auto-registrationย with the Distributor
  • Smart slot managementย (1 slot per CPU for Chrome/Firefox, 1 for Safari)
  • Docker container executionย support
  • Command relayย without evaluation or control

6. Event Bus – The Communication Backbone

The Event Bus eliminates expensive HTTP calls by providing asynchronous message-based communication between components. This publish-subscribe model ensures components stay synchronized while maintaining loose coupling.

Technical advantages:

  • Asynchronous communicationย prevents blocking
  • Reduced HTTP overheadย improves performance
  • Event-driven architectureย enables reactive scaling
  • Component decouplingย improves maintainability

Performance Comparison: Grid 3 vs Grid 4

Architecture Evolution Impact

The architectural transformation delivers measurable performance improvements:

MetricSelenium Grid 3Selenium Grid 4Improvement
Session Creation Speed4-10x slowerBaseline performance85% faster 
Resource UtilizationLimited scalingDynamic scaling50% cost reduction 
Communication ModelSynchronous HTTPAsynchronous Event Bus40% less overhead 
Fault ToleranceSingle point of failureDistributed components99.9% uptime achievable
Docker SupportManual configurationNative support75% setup time reduction 

Implementation Strategies

Setup Modes for Different Scale Requirements

Grid 4 offers three deployment modes to match your team’s specific needs and infrastructure capabilities :

1. Standalone Mode (โ‰ค5 Nodes)

Perfect for small teams or proof-of-concept implementations. All components run in a single process with minimal configuration overhead.

2. Hub and Node Mode (6-100 Nodes)

Traditional hub-node architecture enhanced with Grid 4’s improved communication protocols, IPv6 support, and HTTPS security.

3. Fully Distributed Mode (100+ Nodes)

Enterprise-grade deployment with each component running independently, enabling true horizontal scaling and cloud-native architectures.

Docker Integration Best Practices

Docker containers have become the preferred deployment method for Grid 4, offering consistent environments and easy scaling :

<code># Docker Compose Example for Grid 4
version: '3.8'
services:
  selenium-hub:
    image: selenium/hub:4.15.0
    container_name: selenium-hub
    ports:
      - "4444:4444"
  
  chrome:
    image: selenium/node-chrome:4.15.0
    container_name: chrome
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - SE_NODE_MAX_SESSIONS=3
</code>Code language: PHP (php)

Complete Setup Guide: From Zero to Production

Prerequisites and System Requirements

Before starting, ensure your system meets these requirements:

  • Java 11 or higherย (OpenJDK recommended)
  • Docker and Docker Composeย (for container deployments)
  • Minimum 4GB RAMย per Grid component
  • Network ports:ย 4444 (Hub), 4442-4443 (Node communication), 5555 (Event Bus)

Method 1: Standalone Mode Setup (Fastest Start)

Perfect for small teams or quick testing – everything runs in one process:

Step 1: Download Selenium Server

# Download latest Selenium Server JAR
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.15.0/selenium-server-4.15.0.jar

# Or use curl
curl -L -O https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.15.0/selenium-server-4.15.0.jar

Step 2: Start Standalone Grid

# Basic standalone setup
java -jar selenium-server-4.15.0.jar standalone

# With custom configuration
java -jar selenium-server-4.15.0.jar standalone \
--port 4444 \
--max-sessions 10 \
--session-timeout 300

Step 3: Verify Setup


Method 2: Hub and Node Mode (Traditional Enhanced)

Ideal for medium-scale deployments (6-100 nodes):

Step 1: Start the Hub

# Terminal 1 - Start Hub
java -jar selenium-server-4.15.0.jar hub \
--port 4444 \
--session-timeout 300 \
--session-request-timeout 300

Step 2: Configure and Start Nodes

# Terminal 2 - Chrome Node
java -jar selenium-server-4.15.0.jar node \
--hub http://localhost:4444/grid/register \
--port 5555 \
--max-sessions 3

# Terminal 3 - Firefox Node
java -jar selenium-server-4.15.0.jar node \
--hub http://localhost:4444/grid/register \
--port 5556 \
--max-sessions 3 \
--override-max-sessions

Step 3: Advanced Node Configuration

# Node with specific browser capabilities
java -Dwebdriver.chrome.driver=/path/to/chromedriver \
-jar selenium-server-4.15.0.jar node \
--hub http://localhost:4444/grid/register \
--port 5557 \
--config node-config.json

node-config.json example:

{
"capabilities": [
{
"browserName": "chrome",
"maxInstances": 3,
"version": "latest"
},
{
"browserName": "firefox",
"maxInstances": 2,
"version": "latest"
}
]
}

Method 3: Fully Distributed Mode (Enterprise Scale)

For high-scale deployments (100+ nodes) with maximum flexibility:

Step 1: Start Event Bus (Foundation Component)

# Terminal 1 - Event Bus
java -jar selenium-server-4.15.0.jar event-bus \
--port 4442 \
--publish-events tcp://*:4442 \
--subscribe-events tcp://*:4443

Step 2: Start Session Map

# Terminal 2 - Session Map
java -jar selenium-server-4.15.0.jar sessions \
--port 5556 \
--event-bus-host localhost \
--event-bus-publish-port 4442 \
--event-bus-subscribe-port 4443

Step 3: Start New Session Queue

# Terminal 3 - New Session Queue
java -jar selenium-server-4.15.0.jar sessionqueue \
--port 5559 \
--event-bus-host localhost \
--event-bus-publish-port 4442 \
--event-bus-subscribe-port 4443

Step 4: Start Distributor

# Terminal 4 - Distributor
java -jar selenium-server-4.15.0.jar distributor \
--port 5553 \
--sessions http://localhost:5556 \
--sessionqueue http://localhost:5559 \
--event-bus-host localhost \
--event-bus-publish-port 4442 \
--event-bus-subscribe-port 4443

Step 5: Start Router (Entry Point)

# Terminal 5 - Router
java -jar selenium-server-4.15.0.jar router \
--port 4444 \
--distributor http://localhost:5553 \
--sessions http://localhost:5556 \
--sessionqueue http://localhost:5559

Step 6: Add Nodes to Distributed Grid

# Terminal 6+ - Add Nodes
java -jar selenium-server-4.15.0.jar node \
--port 5555 \
--event-bus-host localhost \
--event-bus-publish-port 4442 \
--event-bus-subscribe-port 4443

The fastest and most reliable setup method:

Docker Compose Setup

Create docker-compose.yml:

version: '3.8'
services:
# Selenium Hub
selenium-hub:
image: selenium/hub:4.15.0
container_name: selenium-hub
ports:
- "4444:4444"
- "4442:4442"
- "4443:4443"
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_SESSION_TIMEOUT=300
networks:
- selenium-grid

# Chrome Nodes
chrome-node-1:
image: selenium/node-chrome:4.15.0
container_name: chrome-node-1
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=3
- SE_NODE_OVERRIDE_MAX_SESSIONS=true
shm_size: 2gb
networks:
- selenium-grid

chrome-node-2:
image: selenium/node-chrome:4.15.0
container_name: chrome-node-2
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=3
shm_size: 2gb
networks:
- selenium-grid

# Firefox Node
firefox-node:
image: selenium/node-firefox:4.15.0
container_name: firefox-node
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=2
shm_size: 2gb
networks:
- selenium-grid

# Edge Node
edge-node:
image: selenium/node-edge:4.15.0
container_name: edge-node
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=2
shm_size: 2gb
networks:
- selenium-grid

networks:
selenium-grid:
driver: bridge

Launch Docker Grid

# Start the Grid
docker-compose up -d

# Check status
docker-compose ps

# View logs
docker-compose logs selenium-hub

# Scale nodes dynamically
docker-compose up -d --scale chrome-node-1=3

# Stop the Grid
docker-compose down

Method 5: Kubernetes Deployment (Cloud-Native)

For enterprise-scale cloud deployments:

Kubernetes Manifests

selenium-hub.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
name: selenium-hub
spec:
replicas: 1
selector:
matchLabels:
app: selenium-hub
template:
metadata:
labels:
app: selenium-hub
spec:
containers:
- name: selenium-hub
image: selenium/hub:4.15.0
ports:
- containerPort: 4444
env:
- name: SE_SESSION_TIMEOUT
value: "300"
---
apiVersion: v1
kind: Service
metadata:
name: selenium-hub-service
spec:
selector:
app: selenium-hub
ports:
- port: 4444
targetPort: 4444
type: LoadBalancer

chrome-node.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
name: chrome-node
spec:
replicas: 3
selector:
matchLabels:
app: chrome-node
template:
metadata:
labels:
app: chrome-node
spec:
containers:
- name: chrome-node
image: selenium/node-chrome:4.15.0
env:
- name: HUB_HOST
value: "selenium-hub-service"
- name: SE_NODE_MAX_SESSIONS
value: "3"
resources:
requests:
memory: "1Gi"
cpu: "0.5"
limits:
memory: "2Gi"
cpu: "1"

Deploy to Kubernetes

# Deploy Hub
kubectl apply -f selenium-hub.yaml

# Deploy Nodes
kubectl apply -f chrome-node.yaml

# Check status
kubectl get pods
kubectl get services

# Scale nodes
kubectl scale deployment chrome-node --replicas=5

# Access Grid UI
kubectl port-forward service/selenium-hub-service 4444:4444

Configuration and Testing

Test Your Setup with Sample Code

Java TestNG Example:

@Test
public void testSeleniumGrid() {
ChromeOptions options = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444"), options);

driver.get("https://www.google.com");
Assert.assertEquals("Google", driver.getTitle());
driver.quit();
}

Python Example:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def test_grid_setup():
options = Options()
driver = webdriver.Remote(
command_executor='http://localhost:4444',
options=options
)

driver.get("https://www.google.com")
assert "Google" in driver.title
driver.quit()

Verify Grid Health

# Check Grid status
curl http://localhost:4444/wd/hub/status

# Check node availability
curl http://localhost:4444/grid/api/hub

Production Monitoring and Maintenance

Health Check Scripts

#!/bin/bash
# grid-health-check.sh
GRID_URL="http://localhost:4444"
STATUS=$(curl -s "${GRID_URL}/wd/hub/status" | jq -r '.value.ready')

if [ "$STATUS" = "true" ]; then
echo "Grid is healthy"
exit 0
else
echo "Grid is unhealthy"
exit 1
fi

Log Configuration

# Enable detailed logging
java -jar selenium-server-4.15.0.jar standalone \
--log-level INFO \
--structured-logs \
--tracing --config logging.properties

Now your setup section is complete with all deployment methods, from simple standalone to enterprise Kubernetes deployments!


FAQ Section

1. What makes Selenium Grid 4 fundamentally different from Grid 3?

Grid 4 is a complete architectural rewrite featuring six specialized components instead of Grid 3’s simple hub-node model. This distributed architecture enables 85% faster performance and 90% cost reduction through optimized resource utilization.

2. How does the Event Bus improve Grid performance?

The Event Bus eliminates expensive HTTP calls by implementing asynchronous message-based communication between components. This reduces communication overhead by 40% and enables reactive scaling.

3. What are the infrastructure cost implications of upgrading to Grid 4?

Organizations report 5-year savings of $1.69 million when upgrading from Grid 3 to Grid 4, primarily through reduced infrastructure requirements and operational overhead.

4. Which deployment mode should my team choose?

Choose based on scale: Standalone for โ‰ค5 nodes, Hub-Node for 6-100 nodes, and Fully Distributed for 100+ nodes. Most teams start with Standalone and scale as needed.

5. How does Docker integration benefit Grid 4 deployments?

Docker provides 75% setup time reduction with consistent environments, easy scaling, and simplified maintenance. Native Docker support eliminates manual configuration complexity.

6. What monitoring capabilities does Grid 4 offer?

Grid 4 includes distributed tracing, enhanced logging, and real-time metrics for comprehensive observability. These features enable proactive issue detection and performance optimization.

7. How do I migrate existing Grid 3 tests to Grid 4?

Grid 4 maintains backward compatibility for most test scripts. The primary changes involve updating Grid server setup and configuration rather than test code modifications.

8. What security features does Grid 4 provide?

HTTPS support, authentication mechanisms, network isolation, and audit logging protect your test infrastructure while meeting compliance requirements.

9. How does Grid 4 handle high-demand testing scenarios?

The New Session Queue with configurable timeouts and Event Bus communication prevent overloading during peak demand, ensuring stable performance under load.

10. What’s the learning curve for teams transitioning to Grid 4?

Most teams achieve proficiency within 2-4 weeks with proper training. The distributed architecture concepts require initial learning, but operational benefits quickly justify the investment.


Share This Knowledge

Found this guide valuable? Help fellow QA professionals master Grid 4 by sharing on LinkedIn, Twitter, and testing communities. Together, we can elevate the entire testing industry.


This comprehensive guide positions you at the forefront of modern test automation architecture. With Selenium Grid 4’s revolutionary distributed components, superior performance, and massive cost savings, you’re not just upgrading your testing infrastructureโ€”you’re future-proofing your QA strategy for the challenges ahead.

QABash Nexusโ€”Subscribe before Itโ€™s too late!

Monthly Drop- Unreleased resources, pro career moves, and community exclusives.

Ishan Dev Shukl
Ishan Dev Shukl
With 13+ years in SDET leadership, I drive quality and innovation through Test Strategies and Automation. I lead Testing Center of Excellence, ensuring high-quality products across Frontend, Backend, and App Testing. "Quality is in the details" defines my approachโ€”creating seamless, impactful user experiences. I embrace challenges, learn from failure, and take risks to drive success.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Advertisement

Related articles

5 Vibe Testing Anti-Patterns That Destroy Your Pipeline (And How to Fix Them)

Why Anti-Patterns Undermine Your Vibe Testing Success Vibe testingโ€”using AI-native frameworks to drive resilient, intent-based automationโ€”promises reduced maintenance and...

Vibe Testing: How AI-Native Tools Are Rewriting Automation Rules

The New Era of Test Automation: From Vibe to AI-Native Self-Healing For years, โ€œvibe testingโ€ referred to rule-based automation...

Vibium AI: The $3.8 Billion Promise That Doesn’t Exist Yetโ€”Why QA Teams Are Going Crazy Over Vaporware

The Most Anticipated Software Tool That You Can't Actually Use The testing world has gone absolutely insane over Vibium AIโ€”Jason Huggins' promised...

Free MCP Course by Anthropic: Learn Model Context Protocol to Supercharge AI Integrations

Model Context Protocol (MCP): The Secret Sauce Behind Smarter AI Integrations If youโ€™ve ever wished you could connect Claude...