← Blog

BLOG

Browser-As-A-Service vs Self-Hosted Playwright Infra

Browser-as-a-service vs self-hosted Playwright infra: compare cost, scaling, session persistence, and production readiness for AI agents.

August 27, 202610 min readRemote Browser

# Browser-As-A-Service vs Self-Hosted Playwright Infra

When your automation workload moves past a handful of scripts, the infrastructure decision becomes unavoidable: browser-as-a-service vs self-hosted Playwright infra. The choice affects your latency, your operational overhead, and how reliably your AI agents can complete tasks. This guide breaks down the real trade-offs so you can pick the right runtime for your production workloads.

Why This Decision Matters Now

Browser automation has shifted from CI/CD test suites to AI agents that browse, extract, and act on the web. These agents have different infrastructure requirements than a nightly test run. They need persistent sessions, live debugging, and the ability to survive network blips without losing state.

Self-hosting Playwright gives you control. Browser-as-a-service (BaaS) gives you managed infrastructure. Neither is universally better—the right answer depends on your team size, traffic patterns, and tolerance for operational work.

What Self-Hosted Playwright Actually Costs

The obvious cost of self-hosting is compute. Each Chromium instance consumes roughly 300–500 MB of RAM. If you run 50 concurrent sessions, that's 15–25 GB of RAM just for browsers, before your application code.

But the hidden costs are bigger:

  • Session management: Keeping browser sessions alive across multiple cloud workers requires a shared state layer. You'll build or integrate a session store, handle reconnection logic, and manage cleanup.
  • Scaling infrastructure: Auto-scaling groups, load balancers, and queue systems for browser requests. Each component needs monitoring and alerting.
  • Network and IP reputation: Residential or clean IPs for sites that block datacenter traffic. This is a rabbit hole of proxy management and IP rotation.
  • Debugging tooling: Live viewing, session recording, and step-by-step replay are non-trivial to build. Most teams end up with console.log statements and screenshots.
  • Maintenance: Chromium updates, Playwright version bumps, and security patches. Every update risks breaking your automation.

For a small team, this is a full-time infrastructure engineer's job. For a larger team, it's a dedicated platform group.

What Browser-As-A-Service Provides

A browser-as-a-service platform like Remote Browser abstracts the infrastructure layer. You get hosted Chromium sessions accessible via CDP, Playwright, or Puppeteer. The platform handles session persistence, scaling, and network configuration.

The practical benefits:

  • Instant scale: Spin up 100 sessions without provisioning anything.
  • Persistent sessions: Browser state survives across cloud workers and API calls.
  • Live debugging: Watch sessions in real time via a live viewer.
  • Managed profiles: Persistent profiles for logged-in states, cookies, and local storage.
  • Configurable browser settings: Proxy settings, viewport, user agent, and other stealth-related options.

The trade-off is less control over the underlying infrastructure. You can't tweak kernel parameters or customize the Chromium build. For most automation workloads, this doesn't matter.

Comparison Table: BaaS vs Self-Hosted

CriterionBrowser-As-A-ServiceSelf-Hosted Playwright
Setup timeMinutes (API key + connect)Days to weeks (infra + config)
ScalingAutomatic, on-demandManual or custom auto-scaling
Session persistenceBuilt-in, survives worker restartsRequires custom state management
Live debuggingIncluded (live viewer, session logs)Build it yourself or use third-party tools
IP/network managementPlatform handles proxy configYou manage proxies, IP rotation, reputation
MaintenancePlatform handles Chromium updatesYou handle version bumps and security patches
Cost modelPer browser-hour, no idle costFixed compute cost, idle or not
ControlLimited to platform APIsFull control over environment
Best forAI agents, production automation, teams without infra resourcesTeams with strong infra expertise, custom browser needs

When Self-Hosting Still Makes Sense

Self-hosting isn't obsolete. It's the right choice when:

  • You need custom Chromium builds: Modified browser binaries for specific fingerprinting or rendering needs.
  • You have strict data residency requirements: Browsers must run in your VPC or on-premises.
  • You already have the infrastructure: Your team runs Kubernetes and manages stateful services daily.
  • Your workload is predictable and steady: A fixed number of sessions running 24/7. The cost of idle compute is acceptable.

If you're running 10–20 concurrent sessions with a stable workload and you have the operational capacity, self-hosting can be cost-effective.

When Browser-As-A-Service Wins

BaaS wins for most AI agent workloads:

  • Bursty traffic: Your agent usage spikes during business hours or after a product launch. You don't want to provision for peak load.
  • Distributed workers: Your agents run across multiple cloud functions or workers. Sessions need to be shared and persistent.
  • Rapid iteration: You're building agents, not infrastructure. Every hour spent on browser infra is an hour not spent on agent logic.
  • Production reliability: You need session recovery, retry logic, and observability without building it yourself.

The Remote Browser API is designed for this. It gives you a simple HTTP/WebSocket interface to hosted Chromium, with session persistence and live debugging built in.

How to Connect Playwright to a Remote Browser

If you're evaluating BaaS, the integration should be straightforward. Here's a TypeScript example using Playwright's CDP connection:

import { chromium } from 'playwright';
import { RemoteBrowser } from '@remote-browser/sdk';

async function runAgentTask() {
  // Create a new browser session on the remote platform
  const session = await RemoteBrowser.createSession({
    // Persistent profile ID for logged-in state
    profileId: 'user-123',
    // Configurable browser settings
    settings: {
      viewport: { width: 1280, height: 720 },
      userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
    },
  });

  // Connect Playwright to the remote Chromium instance via CDP
  const browser = await chromium.connectOverCDP(session.cdpUrl);
  const page = await browser.newPage();

  try {
    await page.goto('https://example.com');
    await page.fill('#search', 'browser automation');
    await page.click('button[type="submit"]');
    
    const results = await page.locator('.result').allTextContents();
    console.log('Results:', results);
    
    // Session stays alive after this function returns
    // Other workers can pick up where this left off
  } finally {
    // Don't close the browser if you want to persist the session
    // await browser.close();
  }
}

The key point: the session persists on the remote platform. If your worker crashes, another worker can reconnect to the same session and continue. This is critical for long-running agent tasks.

Session Persistence Across Cloud Workers

One of the hardest problems in self-hosted browser automation is keeping sessions alive across multiple cloud workers. A worker dies, the browser dies, and the session state is lost. Your agent has to restart from scratch.

BaaS platforms solve this by decoupling the browser process from the worker. The browser runs on the platform's infrastructure. Workers connect and disconnect as needed. The session state—cookies, localStorage, navigation history—lives on the platform.

This is especially important for AI agents that need to maintain context across multiple steps. An agent that logs into a portal, navigates through several pages, and extracts data needs the session to survive any worker failure.

For a deeper dive on this, see our post on keeping browser sessions alive across cloud workers.

The "Chrome Remote Desktop Typing Fix" Problem

A common pain point in browser automation is typing issues. Characters get dropped, input events fire in the wrong order, or the page doesn't register keystrokes. This is often caused by:

  • Latency between the worker and the browser: If the browser is on a different machine, input events have network latency.
  • Event ordering: CDP input events can arrive out of order if not properly sequenced.
  • Focus issues: The browser tab loses focus, and the page doesn't process input.

In a BaaS setup, the browser and the automation client are on different machines, so latency is a factor. However, modern platforms handle this by batching input events and using CDP's Input.dispatchKeyEvent with proper sequencing.

If you're seeing typing issues in your automation, check:

  1. Use `page.type()` instead of `page.fill()` for fields that need keystroke simulation.
  2. Add small delays between keystrokes for pages with heavy JavaScript listeners.
  3. Ensure the page has focus before sending input events.

For production workloads, the platform's network infrastructure matters. A BaaS with low-latency connections to your workers will have fewer input issues.

AI Agent Browser Access in Production

Giving your AI agent browser access in production is different from running a local script. You need:

  • Reliability: The agent must complete tasks without human intervention.
  • Observability: You need to see what the agent is doing, step by step.
  • Safety: The agent should be sandboxed and have limited permissions.
  • Scalability: Multiple agents running concurrently without interference.

A BaaS platform provides these by default. Sessions are isolated, live viewing shows agent actions in real time, and the API supports programmatic control.

Self-hosting requires you to build all of this. Session isolation is easy with separate browser processes, but observability and safety require significant engineering.

Cost Analysis: Browser-Hour vs Fixed Compute

The pricing models differ fundamentally:

Self-hosted: You pay for compute whether you use it or not. A VM running 24/7 costs the same whether it's running one browser or ten. For steady workloads, this is predictable. For bursty workloads, you over-provision.

BaaS: You pay per browser-hour. Idle time costs nothing. This is ideal for workloads with variable demand. The trade-off is that heavy usage can be more expensive than a fixed VM.

The right model depends on your usage pattern. If you run 100 browsers 24/7, self-hosting might be cheaper. If you run 10 browsers during business hours and 0 at night, BaaS is more cost-effective.

Check the current pricing for details on browser-hour rates.

Operational Considerations

Beyond cost, consider the operational burden:

TaskSelf-HostedBaaS
MonitoringSet up Prometheus/Grafana, alertingPlatform provides dashboards and logs
Incident responseYou're on call for browser crashesPlatform handles infrastructure incidents
Security patchingYou track CVEs and update ChromiumPlatform applies patches
Capacity planningYou forecast and provisionPlatform scales automatically
ComplianceYou control data flowPlatform has compliance certifications

For a small team, the operational burden of self-hosting can be the deciding factor. Every hour spent on infrastructure is an hour not spent on your core product.

Making the Decision

Here's a practical framework:

  1. Count your concurrent sessions: If you need more than 20 concurrent browsers, BaaS becomes more attractive.
  2. Assess your team's infra skills: Can you run stateful services in production? If not, BaaS is the safer choice.
  3. Evaluate your traffic pattern: Bursty or unpredictable? BaaS handles this better.
  4. Check your debugging needs: Do you need live viewing and session replay? BaaS provides this out of the box.
  5. Consider your timeline: If you need to ship in weeks, not months, BaaS wins.

The Hybrid Approach

You don't have to choose one or the other. Many teams run a hybrid:

  • Self-hosted for stable, predictable workloads with custom requirements.
  • BaaS for bursty traffic, AI agents, and experiments.

This gives you the best of both worlds. The key is to abstract your browser access behind a common interface so you can switch between runtimes as needed.

Conclusion

The browser-as-a-service vs self-hosted Playwright infra decision comes down to your team's resources and your workload's characteristics. BaaS platforms like Remote Browser eliminate the operational overhead of running browsers at scale, provide session persistence across workers, and offer live debugging for AI agents.

Self-hosting gives you control and potentially lower costs for steady, predictable workloads. But it requires significant infrastructure expertise and ongoing maintenance.

For most AI agent workloads, BaaS is the pragmatic choice. It lets you focus on building your agent, not managing browsers. Start with a remote browser session and see how it fits your workflow.

If you're building AI agents that need reliable browser access, check out our guide on remote web browsers for production automation. And for a deeper look at the runtime layer, see remote control browser for how code and agents drive the web.

For more technical details on the CDP connection, refer to the Chrome DevTools Protocol documentation.