A self-hosted Puppeteer or Playwright scraper is cheap to run and expensive to keep working. In our tests, one headless Chromium browser held five loaded pages in about 740 MB of memory, and an always-on AWS Fargate task big enough for that costs $72 a month. The larger bill is everything around the browser: proxy bandwidth, retries on blocked requests, the HTML cleanup your model needs, and the engineer who patches it all when a target site changes.
This guide measures those costs, shows the same scrape written with Puppeteer and as one call to a web scraping API, and gives a migration plan you can run one domain at a time. It also covers when to keep your own browsers, because a managed API is the wrong tool for some jobs.
TL;DR
- Compute is not the problem. Chromium 159 in the official Playwright Docker image used 245 to 432 MB with one page open and peaked at 740 MB with five. At AWS list prices, a 2 vCPU, 4 GB Fargate task costs $72 a month.
- Bandwidth, blocks, and upkeep are. The four pages we loaded transferred 0.5 to 3.9 MB each. At $3 per GB of residential proxy traffic, 100,000 page loads averaging 1.86 MB cost about $558 before a single retry.
- Raw HTML costs you again at the model. On the same four pages, Markdown used 78% to 96% fewer tokens than rendered HTML.
- The replacement is one request. The Puppeteer script and the API call below return the same fields. The API version cost 1 credit and needed no browser, proxy, or HTML parser on our side.
- Keep Playwright for some jobs. End-to-end tests, pages inside your network, and long interactive sessions still belong in your own browser.
What a self-hosted scraping stack includes
A scraper that runs in production is rarely one script. It is six parts, and each one has an owner on your team whether or not anyone planned for it.
| Part | What you run | What goes wrong |
|---|---|---|
| Browser runtime | Chromium in a container, pinned to a Puppeteer or Playwright version | Zombie processes, out-of-memory crashes, version drift |
| Job queue | Workers, concurrency limits, timeouts | Stuck jobs, duplicate work, uneven load on one domain |
| Proxies | A pool, rotation rules, country targeting | Burned IPs, bandwidth spikes, surprise invoices |
| Fingerprints | User agent, TLS, and automation flags | Blocks that start after a Chrome release or a vendor update |
| Parsing | CSS selectors and an HTML to Markdown step | Selectors that break when the page layout changes |
| Monitoring | Success checks, retries, alerts | HTTP 200 responses that contain a block page |
The browser vendors document the first row themselves. Playwright's Docker guide recommends --init because special treatment of PID 1 "is a common reason for zombie processes", and --ipc=host because without it "Chromium can run out of memory and crash". Puppeteer's troubleshooting guide points to dumb-init for the same zombie problem. On AWS Lambda the common route is @sparticuz/chromium, which ships Chromium as a Brotli archive that has to be decompressed before the first launch. Its README asks for at least 512 MB of memory and recommends 1,600 MB or more.
None of this is hard on its own. It is work that sits outside your product and never finishes.
A managed API takes over the browser runtime, the proxies, the fingerprints, and the HTML to Markdown step. The job queue, the monitoring, and the decision about whether a page is good enough stay with you. Your code still chooses what to fetch and when, validates the fields, maps them into your own records, and retries pages that come back incomplete.
What headless Chromium costs to run: measured
Most numbers you see for headless Chrome memory are quoted without a method, so we measured.
How we tested (November 24, 2026). We ran mcr.microsoft.com/playwright:v1.65.1-noble (about 1 GB compressed) with --init --ipc=host on Docker Desktop for Apple silicon, so the container was linux/arm64. The browser was Chromium 159 at a 1440 by 900 viewport. Memory is the sum of proportional set size (PSS) across every browser process, read from /proc/*/smaps_rollup and sampled every 200 ms. Each page was loaded to the load event and held for five seconds. We ran each mode once, so treat the figures as ballpark numbers for your own sizing, not a benchmark.
| State | Headless shell (Playwright default) | Full Chrome in headless mode |
|---|---|---|
| Browser launched, no pages | 120 MB | 220 MB |
| One page: a Wikipedia article | 245 MB | 407 MB |
| One page: a GitHub repository | 331 MB | 487 MB |
| One page: BBC News front page | 432 MB | 608 MB |
| One page: a sandbox product page | 250 MB | 413 MB |
| Five pages open at once (peak) | 740 MB | 1,255 MB |
The first page is the expensive one because it carries the browser itself. Loaded alone, a page added 125 to 388 MB on top of the idle browser. With five open together, the average was 124 to 207 MB a page. You will see claims that five concurrent tabs need a 16 GB machine. That did not match our run: five pages fit in under 1.3 GB in the heavier mode.
Launch time was small too. Inside a running container the first launch took 304 ms for the headless shell and 428 ms for full Chrome, and later launches took 20 to 40 ms.
Compute is priced to match. AWS Fargate lists $0.04048 per vCPU-hour and $0.004445 per GB-hour for Linux on x86 in US East (N. Virginia), per the AWS price list published November 11, 2026. A 2 vCPU, 4 GB task is $0.0987 an hour, or $72.08 for a 730-hour month. If that task loads five pages at a time and each takes ten seconds, it clears 1,800 pages an hour, so 100,000 pages is about 56 task-hours, or under $6 of on-demand compute.
Memory still causes incidents, for a different reason. A browser that stays up for days accumulates memory and orphaned processes, which is why production fleets recycle browsers on a schedule and watch for the zombie processes the docs warn about. The cost there is attention, not gigabytes.
Where the money goes: bandwidth, blocks, and retries
Proxy bandwidth
A real browser downloads everything a page asks for. Here is what the same four page loads transferred over the network, measured through the Chrome DevTools Protocol:
| Page | Requests | Transferred |
|---|---|---|
| A Wikipedia article | 38 | 0.47 MB |
| A GitHub repository | 139 | 2.07 MB |
| BBC News front page | 188 | 3.94 MB |
| A sandbox product page | 20 | 0.95 MB |
The mean is 1.86 MB per page. That is free on your own connection and metered on a residential proxy, which is what you need once a target blocks datacenter IP ranges. List prices we checked on November 24, 2026: Decodo charges $4 per GB pay as you go and $2.75 per GB on its 100 GB plan, Oxylabs charges $3.50 per GB on its $500 plan, and Bright Data lists $8 per GB pay as you go before a promotion that was running that day.
proxy GB per month = pages x average MB per page / 1,000
proxy cost per month = proxy GB per month x price per GBAt 100,000 pages, 1.86 MB per page, and $3 per GB, that is 186 GB and $558 a month. You can cut it by blocking images, fonts, and media with request interception, and by sending only the domains that need it through the residential pool. Both are more rules to tune per site.
Retries
Blocked requests are paid for and thrown away. The number of requests you send for a given number of good pages is the page count divided by your success rate:
| Success rate | Requests for 100,000 good pages | Multiplier |
|---|---|---|
| 95% | 105,264 | 1.05x |
| 80% | 125,000 | 1.25x |
| 60% | 166,667 | 1.67x |
The multiplier is exact for request count and browser time. For bandwidth it is a ceiling, because a block page is usually smaller than the real page. Your own success rate is the number to measure. It varies by target and by week, and nobody else's figure will predict yours.
Detection
Sites tell automated browsers apart with signals your script does not set on purpose. Two that are easy to see for yourself:
- The browser announces automation. In our tests, a default Playwright launch and a default Puppeteer launch both reported
navigator.webdriverastrueand sent a user agent containingHeadlessChrome. - The TLS handshake is a fingerprint. Cloudflare's documentation says JA3 and JA4 fingerprints "identify TLS clients based on how they initiate connections". That check happens before your first line of page JavaScript runs.
Hiding one signal while leaving another is easy to get wrong, and the right values change with each Chrome release. Keeping them consistent is ongoing work, and a miss shows up as a falling success rate, not as an error in your logs.
Engineering time
We do not have a survey figure for maintenance hours that we trust, so use your own. Count the hours your team spent last month on blocked jobs, broken selectors, proxy issues, and browser upgrades, and multiply by a loaded hourly cost. Ten hours at $100 an hour is $1,000, which is more than every infrastructure line in this post combined.
Raw HTML costs you again at the model
If the scraped page goes to an LLM, its size in tokens is a cost of its own. We scraped the same four pages through the Context.dev API with caching off, asked for rendered HTML and Markdown, and counted tokens with OpenAI's o200k_base encoding.
| Page | Rendered HTML | Markdown | Markdown, main content only |
|---|---|---|---|
| A Wikipedia article | 82,193 | 17,796 (78% fewer) | 14,708 (82% fewer) |
| A GitHub repository | 181,651 | 12,012 (93% fewer) | 10,645 (94% fewer) |
| BBC News front page | 131,502 | 4,735 (96% fewer) | 2,798 (98% fewer) |
| A sandbox product page | 10,758 | 1,043 (90% fewer) | 62 (99% fewer) |
At an illustrative $3 per million input tokens, 1,000 pages like the GitHub one cost about $545 as HTML and $36 as Markdown. Two of the four HTML versions are larger than a 128,000-token context window on their own.
You can build this step yourself with Turndown or Readability, and many teams do. It is the sixth part of the stack to own, and its failures are quiet: a selector for the main content drifts, and navigation links start filling your context window.
The same scrape, before and after
Here is a small, honest version of a self-hosted scraper. It loads a product page through an authenticated proxy, waits for the content, reads two fields with CSS selectors, and converts the product block to Markdown. We ran it with Puppeteer 25.18.1.
import puppeteer from 'puppeteer';
import TurndownService from 'turndown';
const url = 'https://webscraper.io/test-sites/e-commerce/static/product/31';
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-dev-shm-usage', `--proxy-server=${process.env.PROXY_SERVER}`],
});
try {
const page = await browser.newPage();
await page.authenticate({ username: process.env.PROXY_USERNAME, password: process.env.PROXY_PASSWORD });
await page.goto(url, { waitUntil: 'networkidle2', timeout: 30_000 });
await page.waitForSelector('.caption', { timeout: 10_000 });
const name = await page.$eval('.caption .title', (element) => element.textContent.trim());
const price = await page.$eval('.caption .price', (element) => element.textContent.trim());
const html = await page.$eval('.caption', (element) => element.outerHTML);
console.log(new TurndownService().turndown(html));
console.log({ name, price });
} finally {
await browser.close();
}That is 24 lines, and it still has no retry logic, block detection, proxy rotation, concurrency control, or container to run in.
The same result through the Context.dev scrape endpoint with the TypeScript SDK (npm install context.dev, version 3.30.0 here):
import ContextDev from 'context.dev';
const client = new ContextDev();
const page = await client.web.scrape({
url: 'https://webscraper.io/test-sites/e-commerce/static/product/31',
formats: { markdown: true, parse: true },
sharedParams: { mainContentOnly: true, waitFor: '.caption', country: 'US' },
parseParams: { rules: { name: '.caption .title', price: '.caption .price' } },
});
if (!page.markdown.success) {
throw new Error(`${page.markdown.error_code}: ${page.markdown.message}`);
}
console.log(page.markdown.data);
console.log(page.parsed.data);The client reads CONTEXT_DEV_API_KEY from the environment. The second console.log printed:
{ name: 'Packard 255 G2', price: '$416.99' }The request cost 1 credit. Rendering, the proxy, and the Markdown conversion ran on Context.dev's side, and your CSS selectors carried over unchanged into parseParams.rules.
What maps to what
| In Puppeteer or Playwright | In a scrape request |
|---|---|
page.goto plus waitForSelector | sharedParams.waitFor (milliseconds or a CSS selector) |
page.click, typing, scrolling | sharedParams.actions: up to 5 steps, paid plans, base cost 2 credits |
--proxy-server and geo-targeted pools | sharedParams.country |
page.setExtraHTTPHeaders | sharedParams.headers |
page.$eval with CSS selectors | formats.parse with parseParams.rules |
| Field parsers you rewrite after each redesign | formats.json with a JSON Schema in jsonParams.schema (adds 4 credits) |
| Turndown or Readability | formats.markdown and sharedParams.mainContentOnly |
page.screenshot | formats.screenshot |
| Login scripts and saved cookies | sharedParams.profile (paid plans, HTTPS targets) |
| A queue and workers for bulk jobs | Batches, up to 100,000 URLs per job |
Three behaviors differ from a script you run yourself, and they matter during a migration:
- Failures arrive as data. A blocked or missing page returns HTTP 200 with
success: falseand anerror_codeon the affected output. Check each output'ssuccessflag, not only the status code. - Responses can come from cache.
maxAgeMsdefaults to three days. Set it to0when you need a fresh fetch every time, the way your script behaves today. - Concurrency is a plan limit. A request that arrives when every slot is busy gets a 429 with a
Retry-Afterheader. The SDK retries 429 and 5xx responses twice by default.
Cost at 100,000 pages a month
This table uses the measured and list-price inputs above. Swap in your own page weight, proxy rate, and hours.
| Line item | Self-hosted on Fargate | Context.dev |
|---|---|---|
| Compute | $72 for one always-on 2 vCPU, 4 GB task | Included |
| Residential proxy bandwidth | $558 if every page uses one (186 GB at $3 per GB) | Included |
| Retries | Requests and bandwidth divided by your success rate | A response where every output fails is free, except a missing page |
| HTML to Markdown | Your code | Included in the 1-credit page |
| Engineering upkeep | Your hours times your rate | Integration, then your own validation |
| Plan | – | Pro: $90 a month for 100,000 credits, 100 concurrent requests |
If none of your targets block datacenter IPs and your scripts rarely break, self-hosting is cheaper on paper: $72 against $90. The comparison turns as soon as proxies or people enter it. A quarter of your pages on a residential proxy adds about $140, and one hour of upkeep a month at $100 closes the gap on its own.
Two things raise the Context.dev side. JSON extraction against a schema adds 4 credits a page, so 100,000 pages with formats.json use 500,000 credits, which is the $300 Growth plan. Keeping your selectors in formats.parse stays at 1 credit. Browser actions make the base 2 credits. At 1,000,000 pages a month, the Scale plan is $500, or $0.50 per 1,000 pages. Current plans are on the pricing page.
Price is half of the comparison. The other half is how many pages come back with real content. On the November 24, 2026 sample of TRACE, an open benchmark Context.dev runs on about 2,700 fresh pages a week with caching off, Context.dev returned real page data for 96.0% of pages, first of the four APIs tested. Our roundup of web scraping APIs and the benchmarks page have the full tables and method. Run the same check on your own URLs before you decide.
When to keep Puppeteer or Playwright
A scraping API replaces stateless page fetches. It does not replace a browser you control. Keep your own for these:
- End-to-end and UI tests. That is what Playwright is built for, and nothing here changes it.
- Pages that are not public. The API fetches public URLs. Anything on localhost, a VPN, or a private network needs a browser inside that network.
- Long interactive flows. Browser actions cap at 5 steps per request. Browser profiles handle a username and password sign-in, and they do not support MFA, CAPTCHA, passkeys, popup login, or HTTP authentication.
- Many accounts with persistent sessions. Multi-account work on a few sites is a job for an anti-detect browser, not an extraction API.
- Step-by-step browser control without the servers. If your code must stay logged in across many steps or drive the page through the Playwright API, a hosted browser service such as Browserless or Browserbase runs the browsers while your scripts keep control. Our comparison of scraping APIs for JavaScript-heavy sites lays out these architectures side by side.
- Browser features that are not scraping. PDF generation, performance traces, and extension testing need the real thing.
- Scraping as your product. If custom crawl logic or network routing is what you sell, own it.
A common end state is both: Playwright for tests and the handful of flows above, and an API for the stateless page fetches.
A migration plan you can run one domain at a time
- Inventory what you have. For each target domain, write down monthly pages, what the script does (wait, click, log in, which fields), and how often it broke last quarter.
- Write acceptance checks first. Pick 20 to 50 representative URLs per domain, including the pages that break most often. For each one, list the fields that must come back and a check for each: required text, a price that parses as a number, a minimum length. An HTTP 200 is not a check.
- Shadow-run a sample. Send 200 to 500 real URLs per domain through both paths with
maxAgeMs: 0. Count the pages that pass your checks on each side, then divide each path's full cost (credits or compute, proxy traffic, retries) by its accepted pages. Cost per accepted page is the number to compare, not cost per request. The free plan's 1,000 credits a month cover a first domain. - Cut over behind a flag. Move one domain, keep the old path as a fallback for a release or two, and watch your acceptance rate, not the status codes.
- Move the jobs around the fetch. Bulk runs go to Batches. Scheduled re-checks go to Monitors. Link-following crawls go to the crawl endpoint, with the URL map for discovery.
- Retire what the API replaced. Delete the task definitions, restart crons, proxy subscriptions, and HTML cleanup code for the domains you moved. Keep Playwright for tests.
Start with the domain that breaks most often. It has the clearest before and after, and it is the one your team will be happiest to stop maintaining.
When to roll back
Write the rollback rule before the cutover, using the shadow-run numbers as the baseline, so nobody has to debate it during an incident. Flip a domain back to the old path if any of these holds for a full day:
- Its acceptance rate drops below the threshold you set, for example more than 2 points under the old path's shadow-run rate.
- A required field goes missing or changes format on more than 1% of pages.
- Cost per accepted page rises above the old path's.
- Response time at the 95th percentile misses the deadline of the job that uses the data.
Keep the old path deployable until a domain has passed a full release cycle without tripping any of these.
FAQs
Is Puppeteer still a good choice for web scraping in 2026?
Puppeteer and Playwright are still good choices when you need full control of a browser: testing, pages inside a private network, or long interactive flows. For stateless page fetches at volume, a managed scraping API is usually cheaper once you count proxy bandwidth and maintenance hours, because rendering, proxies, and anti-bot handling are included in the per-page price.
How much memory does headless Chrome need per page?
In our November 2026 test of Chromium 159 in the official Playwright Docker image, the browser used 120 to 220 MB with no pages open, 245 to 608 MB with one page loaded, and 740 to 1,255 MB with five pages open at once. The range depends on the page and on whether you run the lighter headless shell or full Chrome in headless mode.
How much does it cost to run Puppeteer or Playwright on AWS Fargate?
At AWS list prices for US East (N. Virginia), a 2 vCPU, 4 GB Fargate task costs $0.0987 an hour, or about $72 for an always-on month. Compute is rarely the large line. Residential proxy bandwidth at $2.75 to $8 per GB and the engineering hours spent on blocked requests and broken selectors usually cost more.
Can a scraping API click buttons, scroll, or log in?
Yes, within limits. The Context.dev scrape endpoint accepts up to 5 browser actions per request on paid plans, including clicks described in plain language, scrolling, and waits. Browser profiles keep a logged-in session for sites with a username and password sign-in. MFA, CAPTCHA, and passkey logins are not supported, so those flows stay in your own browser.
Do I have to rewrite my CSS selectors to migrate?
No. Pass your existing selectors as parseParams.rules with formats.parse, and the fields come back in parsed.data for the 1-credit base price. If you would rather stop maintaining selectors, send a JSON Schema with formats.json and the API extracts matching fields for 4 extra credits.
Does a scraping API return fresh pages or cached ones?
Context.dev serves a cached copy when one is newer than maxAgeMs, which defaults to three days. Set maxAgeMs to 0 to fetch the live page on every request. Requests that use browser actions or custom headers always skip the cache.
Can an AI agent use this without a script?
Yes. Context.dev has a hosted MCP server, so agents in Claude Code, Cursor, and other MCP clients can scrape, crawl, and search directly. The same credits and plan limits apply.