Scaling Web Scraping to 1,000+ Concurrent Browser Sessions

What breaks when browser scraping goes from dozens to thousands of concurrent sessions — memory, IPs, queues, politeness and monitoring — and how to design for it.

Spectrae team · · 8 min read

Your scraper works great on a laptop. It handles 10 URLs at a time, finishes a job in a few minutes, and the code is clean. Then someone asks for 50,000 URLs a day, and the whole thing falls apart.

This isn't a code problem. It's an architecture problem.

The jump from dozens of concurrent sessions to thousands isn't linear. You don't just add more workers and call it done. Memory explodes. IP addresses get flagged. The OS runs out of file descriptors. Browsers crash silently and the process keeps running, burning CPU on nothing.

This guide walks through what actually breaks at scale and how to build a system that holds up.


Why single-machine scrapers hit a wall

A single Playwright browser instance can use several hundred megabytes of RAM on real pages, and stealth Firefox builds can use far more. Run 20 at once and you need many gigabytes. That's already past the limit of most developer machines and many cloud VMs.

It's not just memory. The bottlenecks stack up fast:

Bottleneck What breaks
RAM Browsers crash or the OS kills processes
CPU Page rendering and JS execution starve each other
IP reputation Requests from one IP trigger rate limits or blocks
Bandwidth Parallel page loads saturate the network connection
File descriptors OS limits open sockets per process
/dev/shm Chromium uses shared memory; Docker's 64MB default can cause crashes

You can tune some of these. But you can't tune your way past the fundamental limit: a single machine running a single process can only do so much.

The moment you need real scale — hundreds or thousands of concurrent sessions — you need to distribute the work.


The two architecture patterns that work

Pool model

You maintain a fixed number of browser workers, each capable of handling one session at a time. A job queue feeds work to idle workers. When a worker finishes, it picks up the next job.

This is predictable. You know exactly how many browsers are running at any point, which makes memory planning straightforward. The downside is that you pay for idle capacity when the queue drains.

[Job Queue] → [Worker 1] → [Browser]
           → [Worker 2] → [Browser]
           → [Worker 3] → [Browser]
           → [Worker N] → [Browser]

Queue-based dispatch with auto-scaling

Workers scale up when the queue grows and scale down when it empties. This is more cost-efficient but harder to implement correctly. You need good health checks, graceful shutdown, and careful attention to in-flight jobs when workers spin down.

For most teams, start with the pool model. It's simpler to reason about and debug.


Docker containers and browser isolation

Running browsers in Docker containers gives you isolation, reproducibility, and the ability to kill and replace a misbehaving instance without affecting others.

Prefer one browser per container. Packing multiple browsers into one container makes resource accounting messy and means one crashing browser can affect the others.

A minimal container setup for Playwright Chrome:

FROM mcr.microsoft.com/playwright:v1.58.2-noble

WORKDIR /app
COPY package*.json ./
RUN npm ci

# Fix Chromium's shared memory crash in Docker
ENV CHROMIUM_ARGS="--disable-dev-shm-usage"

COPY . .
CMD ["node", "worker.js"]

Either set a larger shm_size or pass --disable-dev-shm-usage — at scale this is not optional. Docker's default /dev/shm is 64MB, Chromium uses shared memory heavily, and without one of these fixes browsers can crash under load with unhelpful errors. (The environment variable above is read by your own launch code; Playwright doesn't read it automatically, so pass args to chromium.launch() yourself.)

Set container memory limits explicitly. If a browser leaks memory (and they do), you want the container to die and restart cleanly rather than bring down the whole host.


IP and proxy rotation at scale

At 1,000 concurrent sessions, even a large residential proxy pool can struggle if you don't manage it well. The goal is distributing load across IPs so no single address sends suspicious volumes to any one domain.

A few rules that hold up in production:

  • Assign one IP per domain per time window. Don't let two workers hit the same site from the same IP at the same time.
  • Rotate IPs between sessions, not between requests. Rotating mid-session breaks cookies and raises more flags than it avoids.
  • Track IP health. If an IP gets a 429 or a CAPTCHA response, pull it from the active pool for a cooldown period.
  • Match proxy geo to target content. Scraping a US-only site from a European IP is a flag.

A simple Redis-based IP pool works well for this. Workers acquire an IP lease before starting a session and release it when done. Expired leases get reclaimed automatically.


Rate limiting and politeness policies

Hammering a site as fast as possible is a good way to get your entire IP range blocked — and it can create legal exposure and real costs for the site you're scraping. Politeness policies protect both the target site and your scraper's longevity.

Practical defaults that work:

  • Per-domain concurrency cap: No more than 5–10 simultaneous sessions per domain
  • Request delay: 1–3 seconds between requests from the same IP to the same domain
  • Crawl window: Spread scheduled jobs across off-peak hours when possible
  • Robots.txt compliance: Parse and respect Crawl-delay directives
  • Retry backoff: Exponential backoff on 429/503 responses, not immediate retry

These aren't just ethical guidelines. Sites that detect aggressive scraping escalate their defenses. Being polite keeps you under the detection threshold longer.


Offloading browser infrastructure to a remote API

Here's the reality: running a browser pool at scale is a full-time infrastructure problem. You're managing:

  • Container orchestration (Kubernetes or Docker Swarm)
  • Browser version updates and security patches
  • Shared memory configuration
  • Pool sizing and auto-scaling
  • Health checks and crash recovery
  • Proxy integration
  • Monitoring and alerting

That's a significant ongoing engineering cost, and it has nothing to do with your actual scraping logic.

A Browser-as-a-Service platform takes the browser part off your plate. Spectrae runs isolated Chromium and Camoufox sessions you connect to via WebSocket. You use the same Playwright code you already have — just point the connection at Spectrae instead of a local browser. Your queue, workers, proxies policy and politeness rules stay yours.

Pricing is per second: $0.003/min for the standard browser and $0.05/min for the stealth browser. There are no browser containers to manage. Concurrency is the number to plan around: accounts include 2 concurrent sessions, you can add slots from the dashboard, and for sustained volume in the hundreds or thousands of concurrent sessions, talk to us about dedicated capacity before you build around it.


Code example: job queue with concurrent Playwright connections

Here's a practical pattern for processing a large URL list with a concurrency-controlled job queue using BullMQ and Spectrae.

import { Queue, Worker } from "bullmq";
import { chromium } from "playwright";
import Redis from "ioredis";

const connection = new Redis({ maxRetriesPerRequest: null });
// Keep this at or below your account's concurrent-session limit,
// or extra connections will be rejected.
const CONCURRENCY = Number(process.env.SPECTRAE_MAX_CONCURRENT ?? 2);

// Add jobs to queue
const scrapeQueue = new Queue("scrape", { connection });

async function enqueueUrls(urls: string[]) {
  const jobs = urls.map((url) => ({
    name: "scrape-url",
    data: { url },
    opts: { attempts: 3, backoff: { type: "exponential", delay: 2000 } },
  }));
  await scrapeQueue.addBulk(jobs);
}

// Worker processes jobs concurrently
const worker = new Worker(
  "scrape",
  async (job) => {
    const browser = await chromium.connect(
      `wss://browser.spectrae.dev/standard/playwright?key=${process.env.SPECTRAE_API_KEY}`
    );

    try {
      const page = await browser.newPage();
      await page.goto(job.data.url, { waitUntil: "domcontentloaded", timeout: 30000 });
      const content = await page.content();
      // process content...
      return { success: true, url: job.data.url, length: content.length };
    } finally {
      await browser.close(); // ends the session and stops billing
    }
  },
  {
    connection,
    concurrency: CONCURRENCY,
  }
);

worker.on("failed", (job, err) => {
  console.error(`Job ${job?.id} failed:`, err.message);
});

A few things worth noting in this pattern:

  • Each job opens its own session. There's no per-session fee — billing is per second with a 20-second minimum — so short isolated sessions are fine, but very short jobs are better batched into one session with several pages.
  • The finally block ensures browsers always close even when jobs fail. Leaked sessions cost money.
  • BullMQ's attempts and backoff config handles retries automatically with exponential backoff.
  • The worker's concurrency is the number of simultaneous browser sessions. Set it from your account's limit and the target site's tolerance.

Monitoring and observability

At 1,000+ sessions, you will have failures. The question is whether you see them before they compound.

Instrument these metrics at minimum:

  • Queue depth: jobs waiting vs. active workers. A growing queue means you need more concurrency.
  • Session duration: P50, P95, P99. Outlier-long sessions often indicate pages that never finish loading.
  • Failure rate by error type: 429s mean IP/rate issues. Timeouts mean slow targets or overloaded workers. Browser crashes mean infrastructure problems.
  • Success rate by domain: Different sites have different failure modes. Track them separately.

BullMQ exposes queue metrics natively. Pair it with Prometheus + Grafana or push metrics to Datadog. Don't try to debug a 1,000-session system by reading logs.


Cost optimization at scale

A few patterns that reduce cost without hurting throughput:

Block unnecessary resources. Images, fonts, and tracking scripts waste bandwidth and slow page loads. Block them unless the content you need requires them.

await page.route("**/*.{png,jpg,jpeg,gif,svg,woff,woff2}", (route) =>
  route.abort()
);

Set hard timeouts. A session stuck waiting for a slow page is paying for browser time that produces nothing. Cap session time at your P95 expected duration plus a buffer.

Reuse one session for multi-page jobs. If you need to scrape five pages that share session state (logged-in user, cookies), open five pages in one context on one browser instead of five separate sessions.

Prioritize your queue. Not all URLs are equal. High-value targets should jump the queue. BullMQ supports priority natively.

Run non-JS targets without a browser. If a URL returns static HTML, you don't need Playwright at all. A plain HTTP request is far cheaper. Reserve browser sessions for JavaScript-rendered pages only.


Putting it together

Scaling to 1,000+ concurrent sessions isn't about writing faster code. It's about building a system where failures are isolated, resources are bounded, and work flows predictably through a queue.

The architecture is straightforward: a job queue feeds work to concurrent workers, each worker opens a browser session, processes the page, and releases the session. The hard part has always been the browser infrastructure — provisioning, scaling, maintaining, and monitoring the pool.

A managed browser layer removes much of that. With Spectrae you get isolated Chromium and Camoufox sessions over WebSocket, with the Playwright API you already know, and no browser containers or crash cleanup to run. Size your concurrency with us up front if you're planning for hundreds of sessions.

Get an API key with $1 of free credit, or read the docs.