Prompt
How do I set up browser jobs that run in parallel in the cloud?
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
To run browser jobs in parallel in the cloud, you generally want this architecture:
- A job queue to hold work items
- A pool of worker machines/containers that each run one or more browser sessions
- A browser automation framework like Playwright or Selenium
- A scheduler/autoscaler to increase or decrease workers based on load
- Centralized logging/metrics so you can see failures and throughput
Common setup options
Option A: Managed browser/grid service
Use a service that already handles distributed browser execution, such as:
- BrowserStack Automate
- Sauce Labs
- LambdaTest
- A remote Playwright/Chrome grid provider
Best if you want the fastest setup and don’t want to manage infra.
Option B: Containerized workers on cloud
Run your own browser containers on:
- Kubernetes
- AWS ECS/Fargate
- Google Cloud Run / GKE
- Azure Container Apps / AKS
This is the most flexible approach.
Typical cloud architecture
1. Put jobs in a queue
Examples:
- AWS SQS
- Google Pub/Sub
- RabbitMQ
- Redis queue
- Kafka
Each job should contain:
- target URL or scenario
- test data
- timeout
- retry policy
- output destination
2. Run worker containers
Each worker:
- pulls a job from the queue
- launches a browser instance
- executes the automation script
- stores results
- acknowledges the job
Usually each worker runs:
- 1 browser per CPU-heavy task, or
- a small number of concurrent browser contexts if lightweight
3. Parallelism model
You can parallelize in two layers:
- Across workers: multiple machines/containers process different jobs
- Within a worker: multiple browser contexts or tabs, if supported and safe
A simple rule: start with 1 job per worker container for reliability, then optimize later.
4. Autoscaling
Scale workers based on:
- queue depth
- CPU/memory usage
- number of in-flight jobs
Kubernetes examples:
- HPA for CPU/memory
- KEDA for queue-length-based scaling
Practical implementation with Playwright
A common pattern is:
- One Node.js app that reads from a queue
- A Docker image with Playwright installed
- Run many copies of that image in the cloud
Example worker flow:
queue -> worker picks job -> launches chromium -> runs script -> saves result -> finishes
Minimal Docker-based worker design
Dockerfile
FROM mcr.microsoft.com/playwright:v1.49.0-jammy
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
CMD ["node", "worker.js"]
worker.js
const { chromium } = require('playwright');
async function runJob(job) {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto(job.url, { waitUntil: 'networkidle' });
const title = await page.title();
await browser.close();
return { title };
}
// pseudo-code for queue loop
async function main() {
while (true) {
const job = await getNextJobFromQueue();
if (!job) {
await sleep(2000);
continue;
}
try {
const result = await runJob(job);
await saveResult(job.id, result);
await ackJob(job.id);
} catch (err) {
await retryOrFail(job, err);
}
}
}
main();
Important best practices
- Use ephemeral workers: easier recovery and scaling
- Set timeouts for page load, navigation, and whole job
- Limit concurrency per machine to avoid memory spikes
- Isolate jobs so one failure doesn’t kill others
- Store artifacts like screenshots, traces, and logs in object storage
- Use retries carefully for flaky network issues
- Keep browser versions pinned for consistency
If you want maximum scale
Consider:
- Kubernetes + autoscaler
- Stateless workers
- Queue-driven dispatch
- Separate storage for artifacts
- Node.js or Python workers with Playwright
If you want the easiest path
Use:
- BrowserStack / Sauce / LambdaTest
- Playwright Test sharding
- Managed CI runners with multiple jobs
If you want, I can give you:
- a Kubernetes setup,
- an AWS ECS/Fargate setup, or
- a Playwright queue worker example you can copy/paste.