Running headless Chrome yourself costs less compute than most people expect and more attention than most people plan for. On a container limited to 2 CPUs and 4 GB, we took 100 screenshots of real sites in about two minutes, using under 1 GB of memory, when we ran four at a time with a fresh browser context for each. Eight at a time was slower, not faster, and pushed the slowest captures to within two seconds of our 30-second timeout. This article gives the full measurements, the code we used, and the things a screenshot API takes off your hands, so you can decide which side of the line you are on.
How we measured
- Where: a Docker container capped with
--cpus 2 --memory 4g --shm-size 1g, roughly a small VPS. Docker's documentation describes --memory as "the maximum amount of memory the container can use"; --cpus caps CPU time. The host was an Apple M5 Mac, with Docker's Linux VM given 8 CPUs.
- Browser: Debian 12's Chromium 155.0.8059.79, driven by puppeteer-core 24.43.1 on Node 20, launched with
--no-sandbox (more on that below).
- Pages: 25 public sites (example.com, mozilla.org, MDN, web.dev, w3.org, python.org, nodejs.org, github.com, gitlab.com, apple.com, gov.uk, bbc.co.uk, theguardian.com, stripe.com, vercel.com, cloudflare.com, wordpress.org, php.net, rust-lang.org, go.dev, debian.org, ubuntu.com, Hacker News, nasa.gov, who.int), each visited four times for 100 captures per run.
- Each capture: a 1280 × 800 viewport,
goto with waitUntil: "load", then a PNG. Every step had a 30-second deadline.
- Memory: read from the container's own cgroup files every 250 ms. The kernel's cgroup documentation says
memory.current counts page cache as well as program memory, so we report two figures: the cgroup peak (memory.peak, everything) and the peak of anon from memory.stat (memory the processes actually allocated, without file cache).
- CPU:
usage_usec from cpu.stat, before and after each run.
We ran six setups, all on 7 November 2026. The first two were run twice, because the first pass had no anon/cache split; the table uses the second pass.
The results
| Setup | Time for 100 | Median capture | Failed | CPU seconds | Peak anon memory | Peak cgroup memory |
|---|
| One page reused, 1 at a time | 81 s | 0.67 s | 0 | 142 | 1,214 MiB | 1,567 MiB |
| New context per capture, 1 at a time | 159 s | 1.18 s | 1 | 249 | 543 MiB | 758 MiB |
| New browser per capture, 1 at a time | 195 s | 1.54 s | 1 | 313 | not split | 544 MiB |
| New context per capture, 4 at a time | 126 s | 4.40 s | 0 | 251 | 961 MiB | 1,158 MiB |
| New context per capture, 8 at a time | 179 s | 12.49 s | 0 | 358 | 1,780 MiB | 2,188 MiB |
| New context, 4 at a time, full page | 209 s | 7.40 s | 1 | 402 | 1,447 MiB | 2,109 MiB |
"Median capture" is the time from starting a capture to having its PNG, so in the concurrent rows it includes waiting for CPU behind the other tabs. Every failure was ubuntu.com, whose load event didn't fire within 30 seconds on that visit; in the one-at-a-time runs, its other visits took under 2.5 seconds. Each timeout costs the full 30 seconds plus a browser restart: the first pass of the "new context, 1 at a time" row had two of them and took 183 s instead of 159 s.

What the numbers say
Two CPUs saturate at about four tabs. Four at a time finished 100 captures in 126 s, using 251 CPU seconds: two full CPUs for the whole run. Eight at a time had no more CPU to use, so it spent 43% more CPU seconds (358) on the same work, nearly doubled peak memory, and took 179 s. Its slowest 5% of captures took 28.7 s or more, just over a second short of our timeout. On a busier set of pages, that setup would start failing captures that the four-tab setup completes.
Reusing one page is the fastest and the leakiest choice. It took 81 s because nothing is torn down between captures, and the second to fourth visit to each site can use the browser's cache. It also held twice the memory of a fresh context per capture, and it carries cookies, storage and consent choices from one site to the next. Puppeteer's documentation says a new browser context "won't share cookies/cache with other browser contexts", which is exactly why the context-per-capture rows are slower and smaller. For screenshots of unrelated sites, or for different customers, take the context.
Launching a browser per capture is the slowest. Each launch and shutdown added about a third of a second to the median and 26% more CPU than reusing one browser with fresh contexts. Its cgroup peak is the lowest because each browser, with its cache, is gone after every capture.
Full-page captures cost about twice as much. The same four-tab setup with fullPage: true used 60% more CPU, took 66% longer, and wrote 100 MB of PNGs instead of 26.5 MB.
As a rough throughput figure, the four-tab setup did 100 viewport captures in 126 s, about 2,860 an hour on 2 CPUs. Your pages will differ; heavy pages, full-page captures and slow sites all pull that down.
The pool we used
This is the structure behind the context-per-capture rows, cut down to four URLs and two at a time. Puppeteer's ScreenshotOptions has no timeout property, so each step gets a deadline of its own, and each capture gets its own context that is closed even when the capture fails. We ran it with Puppeteer 25.16.0:
import puppeteer from "puppeteer";
import { writeFile } from "node:fs/promises";
const STEP_TIMEOUT = 30_000;
function capped(promise, what) {
let timer;
const deadline = new Promise((_, reject) => {
timer = setTimeout(() => reject(new Error(`${what} timed out`)), STEP_TIMEOUT);
});
return Promise.race([promise, deadline]).finally(() => clearTimeout(timer));
}
async function capture(browser, url, file) {
const context = await browser.createBrowserContext();
try {
const page = await context.newPage();
await page.setViewport({ width: 1280, height: 800 });
await capped(page.goto(url, { waitUntil: "load", timeout: STEP_TIMEOUT }), "goto");
await writeFile(file, await capped(page.screenshot(), "screenshot"));
} finally {
await capped(context.close(), "close").catch(() => {});
}
}
const urls = ["https://example.com/", "https://www.python.org/", "https://go.dev/", "https://www.w3.org/"];
const CONCURRENCY = 2;
const browser = await puppeteer.launch();
let next = 0;
await Promise.all(
Array.from({ length: CONCURRENCY }, async () => {
while (next < urls.length) {
const i = next++;
const started = Date.now();
try {
await capture(browser, urls[i], `pool-${i}.png`);
console.log(`ok ${urls[i]} ${Date.now() - started} ms`);
} catch (error) {
console.log(`fail ${urls[i]} ${error.message}`);
}
}
}),
);
await browser.close();
Output:
ok https:
ok https:
ok https:
ok https:
A deadline stops your code waiting, but it doesn't stop the browser. In the benchmark, when a capture timed out with nothing else running, we closed the whole browser and launched a new one before the next capture. Our earlier comparison of Puppeteer and Playwright shows a real page that makes screenshot() wait for ever.
The costs that aren't CPU or memory
When we looked at this machine before running the benchmark, a test process from the previous day was still alive: one Node process and five Chrome processes, 228 MiB resident, idle for 24 hours. Nothing had crashed, so nothing had restarted or killed it. On a server, that is memory you lose until someone notices. Puppeteer's troubleshooting guide recommends docker run --init (or dumb-init) to reap zombie Chrome processes, which helps with dead children but not with a live process stuck waiting; for that you need the deadlines above plus an outer limit on each job.
The rest of the list:
- The sandbox. We launched with
--no-sandbox, as many container setups do. Puppeteer's guide says running without a sandbox is "strongly discouraged" unless you absolutely trust the content you open. Screenshotting arbitrary customer URLs is the opposite of that, so a production setup needs a non-root user with the sandbox on.
- Disk and image size. Debian's
chromium and chromium-common packages install about 354 MiB, before the fonts that non-Latin pages need. Our test image was 1.07 GB.
- Two browsers to choose from. Chrome's documentation says the old headless mode is now a separate binary,
chrome-headless-shell; new headless shares code with regular Chrome. In our earlier tests the two gave different full-page heights for some sites, so pick one and pin its version.
- Network safety. A service that opens any URL a user gives it can be pointed at your own internal addresses. Blocking that takes a filtering proxy or firewall rules, not a line of code.
What an API takes off you, and what it doesn't
A screenshot API runs the pool, the timeouts, the restarts, the sandbox, the fonts and the network filtering, and you pay per capture. For scale, our own plans are $9 a month for 2,000 screenshots, $19 for 10,000 and $79 for 100,000, and the free tool covers occasional captures.
What it doesn't do is make a capture faster than a local browser on a fast page. An API call adds a network round trip and the provider's queue to every capture, and we didn't time that here; measure it with your own pages before you decide.
A fair way to choose:
- If you need a few hundred captures a month, or you're capturing pages you don't control, an API is cheaper than the time it takes to run Chrome safely.
- If you need tens of thousands of captures of your own pages, inside your own network, running Chrome yourself is cheap in hardware: two CPUs managed about 2,860 viewport captures an hour in our test. Budget for the work in the previous section, not just the server.
- Whichever you pick, measure your own pages. Our 25 sites mostly loaded in one or two seconds; a set of heavy pages would move every number in the table.