π― Template Repository: Fork this repo to create your own distributed Playwright testing infrastructure!
A distributed browser testing framework for running large-scale Playwright tests across multiple Railway containers. This is a template repository - fork it and add your own tests!
Click the button above to deploy the complete infrastructure to Railway. This will:
- Set up the worker service with all environment variables
- Configure S3-compatible storage (Railway Buckets recommended)
- Create the orchestrator service
- Connect everything automatically
After deploying the template, you need to create your own fork:
- Go to your Railway project dashboard
- Click on any service (e.g., worker)
- Go to the Settings tab
- Find Source Repo section
- Click "Eject" button
Railway will automatically:
- Create a fork of the repository in your GitHub account
- Connect the fork to your Railway project
- Handle the monorepo structure for all services
Now clone your own repository:
git clone https://github.com/YOUR_USERNAME/playwright-easyscale.git
cd playwright-easyscale
# Install orchestrator dependencies locally
cd orchestrator && npm installCreate your Playwright tests in worker/tests/:
// worker/tests/my-test.spec.js
const { test, expect } = require('@playwright/test');
const userRangeStart = parseInt(process.env.USER_RANGE_START || '1');
const userRangeEnd = parseInt(process.env.USER_RANGE_END || '1');
for (let userId = userRangeStart; userId <= userRangeEnd; userId++) {
test(`User ${userId} workflow`, async ({ page }) => {
// Your test logic here
});
}# Test locally (dry run)
cd orchestrator
node src/index.js --config=../configs/example.json --dry-run
# Deploy to Railway
node src/index.js --config=../configs/example.jsonAll Railway credentials and storage configuration are already set up via the template!
Break free from single-machine hardware limits!
This project solves the fundamental problem of running large-scale browser tests: your local machine can't handle hundreds of concurrent browser instances. Traditional approaches like Puppeteer clusters quickly hit CPU, memory, and network bottlenecks on a single machine.
Playwright EasyScale distributes your tests across multiple Railway containers, giving you:
- Unlimited horizontal scaling - Add more containers, not more RAM
- Unlimited vertical scaling - Each container gets dedicated resources
- No hardware constraints - Break through the limits of a single machine
- π§ͺ Stress Testing - Simulate hundreds or thousands of concurrent users
- π Load Testing - Test application performance under realistic load
- π Large Test Suites - Run massive regression suites in parallel
- π₯ Multi-User Scenarios - Test complex user interactions at scale
The Problem: Running 100+ concurrent browser instances on one machine causes:
- Memory exhaustion
- CPU throttling
- Network saturation
- Flaky tests due to resource contention
The Solution: Distribute tests across cloud containers where each gets dedicated resources. Scale horizontally by adding more containers, not by buying bigger machines.
- π Automatic Distribution - Splits tests across N containers automatically
- π° Cost Effective - Pay only for test duration (~$0.20 per 200-user test)
- π Centralized Logging - Aggregates logs from all containers to S3-compatible storage
- π§ Simple Configuration - JSON-based test configuration
- β‘ Railway Template - One-click deployment, no infrastructure setup
- β»οΈ Template Repository - Fork and customize for your needs
playwright-easyscale/
βββ orchestrator/ # Coordinator service (runs locally)
β βββ src/
β β βββ index.js # Main CLI
β β βββ config.js # Configuration loader
β β βββ distributor.js # User distribution logic
β β βββ railway.js # Railway API client
β β βββ logger.js # Logging utilities
β βββ package.json
β
βββ worker/ # Test runner container (runs on Railway)
β βββ tests/ # π Add your tests here!
β β βββ example.spec.js
β βββ helpers/
β β βββ utils.js
β β βββ logUpload.js
β βββ index.js # Centralized worker service (main entry point)
β βββ state-manager.js # Worker state management
β βββ upload-results.js # Result upload handler (modular)
β βββ Dockerfile
β βββ playwright.config.js
β βββ package.json
β
βββ test-app/ # Demo app for example tests (optional)
β βββ index.html # Simple login/dashboard app
β βββ Dockerfile # For Railway deployment
β βββ README.md # Deployment instructions
β
βββ configs/ # Test configurations
β βββ example.json # π Copy and customize this!
β
βββ docs/ # Documentation
βββ SETUP.md
The orchestrator runs on your machine and:
- Reads test configuration
- Calculates optimal container distribution
- Deploys worker containers to Railway via API
- Passes unique environment variables to each container
- Monitors deployment status
- Aggregates results from storage
Each worker container runs a centralized service (index.js) that:
- Reports "ready" state when deployed
- Waits for "start" command from orchestrator
- Spawns Playwright as a child process
- Runs a subset of users (e.g., users 1-5, 6-10, etc.)
- Executes Playwright tests in parallel (5 workers per container)
- Monitors for "stop" command during execution
- Kills Playwright process tree when stopped
- Uploads logs and screenshots to S3-compatible storage
- Reports "finished" or "stopped" state when complete
Key Architecture: Single Node.js process manages the entire worker lifecycle, ensuring reliable state transitions and proper process management.
Configuration: 100 users, 5 users per container
Container 1: Users 1-5 (5 users)
Container 2: Users 6-10 (5 users)
Container 3: Users 11-15 (5 users)
...
Container 20: Users 96-100 (5 users)
Each container receives:
USER_RANGE_STARTandUSER_RANGE_ENDSHARD_INDEXandSHARD_TOTAL- Custom environment variables from config
Create a config file in configs/:
{
"name": "My Stress Test",
"totalUsers": 100,
"usersPerContainer": 5,
"testFile": "my-test.spec.js",
"environment": {
"LOGIN_URL": "https://your-app.com",
"PASSWORD": "test-password"
},
"railway": {
"projectId": "${RAILWAY_PROJECT_ID}",
"serviceId": "${RAILWAY_SERVICE_ID}",
"apiToken": "${RAILWAY_API_TOKEN}"
},
"storage": {
"endpoint": "${S3_ENDPOINT}",
"accessKey": "${S3_ACCESS_KEY}",
"secretKey": "${S3_SECRET_KEY}",
"bucket": "${S3_BUCKET}",
"region": "${S3_REGION}"
},
"options": {
"headless": true,
"timeout": 300000,
"retries": 0,
"maxConcurrency": 5
}
}Important: You don't need to replicate the full cloud infrastructure locally. The point of this project is to leverage cloud resources to overcome hardware limits. Local development is only for writing and testing individual test logic.
- Node.js 18+ (for running orchestrator and Playwright)
-
Write your tests in
worker/tests/:cd worker npm install # Run a single test locally to verify logic npx playwright test tests/my-test.spec.js --headed
-
Test the orchestrator (dry run to verify configuration):
cd orchestrator npm install # Verify your config and distribution plan node src/index.js --config=../configs/my-test.json --dry-run
-
Deploy to Railway for actual scale testing:
# This deploys N containers to Railway node src/index.js --config=../configs/my-test.json
Why not test locally at scale? Because that defeats the purpose! Running 100 browser instances locally will hit the exact hardware limits this project solves. Write tests locally, deploy to Railway for scale.
- Setup Guide - Complete setup instructions
- Architecture - Worker state management architecture
- Web UI Setup - Web dashboard setup
- Contributing - How to contribute
- License - MIT License
β Ready for Testing
This is a functional template repository with:
- β Working orchestrator with Railway API integration
- β Worker container with Playwright and log upload
- β Example tests and configuration
- β Documentation and setup guides
β Recently Added:
- Web UI dashboard for managing test runs
- Worker state management (ready/testing/finished/stopped)
- Start/Stop/Reset controls for test runs
- Real-time worker status monitoring
- Real-time log streaming in UI
- Advanced error recovery
- Automatic retry logic
cd orchestrator
node src/index.js --config=../configs/example.json --dry-runOutput:
π Playwright EasyScale Orchestrator
β Configuration loaded and validated
π Distribution Plan:
Test: Example Stress Test
Total Users: 20
Users per Container: 5
Total Containers: 4
Container Breakdown:
Container 1: Users 1-5 (5 users)
Container 2: Users 6-10 (5 users)
Container 3: Users 11-15 (5 users)
Container 4: Users 16-20 (5 users)
β Dry run complete - no containers deployed
node src/index.js --config=../configs/example.jsonFor testing purposes, here are 10 test user credentials in JSON format:
[
{"email": "user1@example.com", "password": "TestPass123!"},
{"email": "user2@example.com", "password": "TestPass123!"},
{"email": "user3@example.com", "password": "TestPass123!"},
{"email": "user4@example.com", "password": "TestPass123!"},
{"email": "user5@example.com", "password": "TestPass123!"},
{"email": "user6@example.com", "password": "TestPass123!"},
{"email": "user7@example.com", "password": "TestPass123!"},
{"email": "user8@example.com", "password": "TestPass123!"},
{"email": "user9@example.com", "password": "TestPass123!"},
{"email": "user10@example.com", "password": "TestPass123!"}
]Usage: Copy this JSON array and paste it into the test parameters field when creating a run in the web UI.
This is a template repository - feel free to:
- Fork it and customize for your needs
- Submit PRs with improvements
- Report issues or request features
- Share your use cases
See CONTRIBUTING.md for guidelines.
MIT License - see LICENSE for details.
Built with:
- Playwright - Browser automation
- Railway - Container hosting
- AWS S3 SDK - Storage integration
- π Documentation
- π Issue Tracker
- π¬ Discussions
Made with β€οΈ by CultureDrivers
Fork this repo and start scaling your Playwright tests today! π