Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk8 min

How to Load Balance Headless Browser Sessions

A practical guide to browser-session concurrency: queue jobs, cap active sessions, close every session reliably, and validate managed or self-hosted capacity.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Load balance headless browser sessions by putting jobs in a queue, limiting how many browser sessions can be active at once, and releasing each capacity slot in unconditional cleanup. A managed browser service may queue excess work for you; a self-hosted fleet needs its own worker and scaling policy. In both cases, an application-side limit helps protect target websites and makes backlog visible.

What session concurrency means

A browser session is an active browser connection doing work for a job. Concurrency is the number of sessions active simultaneously—not the number of jobs waiting in a queue or the total jobs processed over time. Browserless defines concurrency as “the maximum number of browser sessions that can run simultaneously on a Browserless instance” (Browserless terminology).

If a service or deployment allows 10 active sessions, launching an eleventh does not create more capacity. It may wait, fail, or time out depending on the service and its current configuration. Treat the limit as a capacity ceiling and confirm the actual behavior for your provider, plan, and endpoint.

Use a bounded control loop

A reliable design separates job intake from session execution. A queue absorbs bursts; a bounded worker pool or semaphore controls how many jobs may hold browser sessions concurrently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Enqueue work. Store each requested URL or automation task in a queue rather than starting an unbounded number of browser connections.
  2. Set an application cap. Choose an initial maximum number of active sessions that fits the capacity you intend to consume. Leave headroom if other clients share the provider or deployment.
  3. Acquire a slot before connecting. A worker waits for a semaphore or an available worker before launching or connecting to a browser.
  4. Run the task and record its outcome. Track success, failure, and elapsed session time so that slow jobs and retries do not silently accumulate.
  5. Close and release in all cases. Put session closure and slot release in a finally block or equivalent, including when navigation, page actions, or result handling throws an error. Browserless warns that failing to close sessions can exhaust concurrency (Best Practices).
  6. Adjust from observed behavior. Monitor active sessions, queued jobs, session duration, failures, and provider capacity or pressure signals when available. Raise or lower the cap based on load tests and target-site limits, not a universal sessions-per-machine formula.

Example: bounded Python workers with local Playwright

This example runs at most four local Chromium sessions at once. It uses a fixed worker pool, so incoming URLs wait in the queue instead of creating unlimited browser processes. Install Playwright and its Chromium build with pip install playwright and playwright install chromium. Save as capture.py and pass URLs on the command line.

import asyncio
import sys
from playwright.async_api import async_playwright

MAX_SESSIONS = 4

async def capture(browser, url):
    context = await browser.new_context()
    try:
        page = await context.new_page()
        await page.goto(url, wait_until="domcontentloaded", timeout=30_000)
        title = await page.title()
        print(f"{url}t{title}")
    finally:
        await context.close()

async def main(urls):
    queue = asyncio.Queue()
    for url in urls:
        queue.put_nowait(url)
    for _ in range(min(MAX_SESSIONS, len(urls))):
        queue.put_nowait(None)

    async with async_playwright() as playwright:
        browser = await playwright.chromium.launch(headless=True)

        async def worker():
            while True:
                url = await queue.get()
                try:
                    if url is None:
                        return
                    try:
                        await capture(browser, url)
                    except Exception as error:
                        print(f"FAILED {url}: {error}", file=sys.stderr)
                finally:
                    queue.task_done()

        try:
            await asyncio.gather(*[worker() for _ in range(min(MAX_SESSIONS, len(urls)))])
        finally:
            await browser.close()

if __name__ == "__main__":
    asyncio.run(main(sys.argv[1:]))

The worker count is the concurrency cap in this local example. For remote sessions, retain the same bounded-worker structure but connect each worker to the provider’s documented endpoint and use the provider’s supported session-closing method. Do not copy an endpoint hostname from an old example: regional URLs and connection details can change.

Managed service queueing and application-side limits

Some managed services queue session requests when capacity is occupied. Browserless documents automatic queuing and also recommends a client-side concurrency cap so clients do not overwhelm a target website (concurrent sessions; terminology).

Provider queueing is burst handling, not a replacement for workload control. An application-side limit helps you keep the rate of activity against a site within your own policy, bound the number of open client connections, and observe local queue latency. Queued requests can still affect latency, throughput, and timeout risk; verify how queueing works for the selected provider and plan.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing the application cap

  • Start below the confirmed provider or deployment maximum, especially when capacity is shared.
  • Load-test representative pages and tasks, including slow navigation, heavy resources, and failure cases.
  • Set timeouts for connection and page operations, and ensure timed-out work still closes its session.
  • Use a separate limit for a target website if its acceptable request rate is lower than your browser capacity.
  • Scale the cap gradually while watching queue depth, job latency, errors, and capacity pressure.

Managed browser service or self-hosted fleet?

Managed and self-hosted deployments can both serve remote browser sessions. The choice is primarily about operational ownership and control; the available documentation does not establish a general cost or performance break-even point.

Decision Managed browser service Self-hosted fleet
Operations Provider operates the browser pool and runtime. Your team operates deployment, capacity, and updates.
Control Use provider endpoints and supported controls. More direct control over deployment and configuration.
Capacity behavior Plan limits and provider queueing may apply; verify current terms. Your team configures and operates concurrency in the deployment.
Geography Choose from the provider’s currently supported regions. Choose infrastructure regions under your control.
Validation Confirm current quotas, timeouts, endpoint regions, and session semantics. Validate worker sizing, scaling, health, browser updates, and cleanup.

Browserless documents both managed browser usage and scaling through worker size or additional worker instances (Browsers as a Service). Its documentation does not provide a portable sessions-per-CPU or sessions-per-GB sizing rule. For self-hosting, load-test the actual pages, browser builds, contexts, and resource profiles you expect to run before setting production capacity.

Region and remote Playwright connection details

When network latency matters, select a supported region close to the workload or users, then verify the endpoint map before deployment. Browserless recommends a nearby region to reduce latency and publishes connection URL and endpoint guidance at Connection URLs and Endpoints. Regional availability and hostnames are vendor details that can change.

For Playwright connections using Chrome DevTools Protocol (CDP), Browserless’s concurrent-session examples advise using the default context when launch-level proxy or profile settings need to carry through. A newly created context may not inherit those settings. Validate this behavior against the endpoint and Playwright/library versions you actually deploy (Run concurrent browser sessions).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost controls

  • Measure session duration, not just job count. A few long-running sessions can occupy the whole pool even when the queue is small.
  • Prevent leaks. Close pages, contexts, and remote sessions in unconditional cleanup. A worker should return its capacity slot after success, timeout, or exception.
  • Bound retries. Retrying immediately can multiply load during a provider outage or target-site failure. Use a finite retry policy and avoid holding a browser session while waiting through a long backoff.
  • Watch queue delay separately from browser time. A job may be slow because it waited for capacity, because the page loaded slowly, or both.
  • Check current plan limits. Provider concurrency and maximum session-duration limits are plan-specific and may change. Browserless’s live Best Practices documentation is the place to verify current limits; do not treat old numeric tables as stable.
  • Align capacity with target-site policy. Your browser fleet’s maximum capacity is not a recommendation to send that many simultaneous requests to every site.

Common failure modes and fixes

Symptom Likely cause What to check or change
New sessions wait or time out The active-session cap is occupied or provider queueing exceeds the request timeout. Check active sessions and queue delay; confirm provider quota and queue behavior; reduce offered concurrency or increase a timeout only when appropriate.
Capacity remains exhausted after jobs finish A remote session or context was not closed on an exception path. Move cleanup into finally; verify the provider’s close semantics and inspect active-session metrics.
Target site blocks or slows requests Concurrency is too aggressive for the destination even if the browser service accepts it. Apply a per-site cap, reduce concurrency, and use measured outcomes to set a sustainable rate.
Remote connection is unexpectedly slow The chosen region is far from the workload, or the endpoint is not the intended regional endpoint. Verify the current endpoint map and use a supported nearby region.
Proxy or profile settings are missing A Playwright CDP connection created a context that did not inherit launch-level settings. Test with the default context as advised in the provider’s example, and confirm behavior for deployed versions.
Self-hosted workers overload or crash Worker capacity was estimated without representative workload testing. Load-test the actual browser version, pages, context setup, and resource usage; scale worker size or instance count based on observed behavior.

Or skip the browser setup

For screenshot jobs rather than general-purpose browser automation, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns an image or PDF; cookie banners, newsletter popups, and chat widgets are removed before capture, and each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, with response headers indicating the page verdict and billing status. Its MCP server includes tools for AI agents to take screenshots, get page information, and capture PDFs.

Example cURL request (replace the target URL and use your API key):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up free for 1,000 screenshots a month with no card.

Deployment checklist

  • What is the confirmed maximum number of simultaneously active sessions for this service, plan, or fleet?
  • Does the provider queue excess connections, and what queue and timeout behavior applies?
  • Is the application cap bounded, and is there a separate concurrency limit for sensitive target sites?
  • Does every success, failure, timeout, and cancellation path close the browser session and release capacity?
  • Are the endpoint hostname, supported region, and remote-connection semantics current for the deployed library version?
  • For self-hosting, have representative pages and resource profiles been load-tested rather than sized by a generic sessions-per-CPU estimate?
  • Are active sessions, queue depth, queue delay, session duration, failures, and capacity pressure visible to operators?

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.