logo of Screenshot for Web
Free toolsPlaygroundDocsBlogPricing
LoginDashboard

Company

HomeFeaturesPricingBlogFacts

Screenshot Tools

Website ScreenshotsFull Page ScreenshotsScrolling ScreenshotsWebsite HistoryPDF Generation APIScreenshot API

Legal

Terms of UsePrivacy PolicyCookie PolicyCopyrightSecurity

Support

FAQSupportContact UsAPI Status
screen shot for web logo

No clutter. No distractions. Just clean, full-page screenshots with smart customization.

© 2026 HYDRANODE LTD. All rights reserved.

Screenshot for Web is operated by HYDRANODE LTD, a company registered in England and Wales, company number 15672526. Registered office: 124 City Road, London, London, England, EC1V 2NX.

FacebookInstagramLinkedInYouTube
  1. Home
  2. Blog
  3. Research

Running headless Chrome yourself vs a screenshot API: memory and time for 100 captures

We ran 100 real-site captures six ways on a 2-CPU, 4 GB container and measured time, CPU, memory and failures, to show what self-hosting really asks of a server.

Screenshot for Web·November 7, 2026·7 min read

Sources

  1. Puppeteer: Troubleshooting (running in Docker, --init, the sandbox)
  2. Puppeteer: Browser.createBrowserContext()
  3. Puppeteer: ScreenshotOptions interface
  4. Linux kernel: Control Group v2 (memory.current, memory.peak, memory.stat, cpu.stat)
  5. Docker: Resource constraints (--memory and --cpus)
  6. Chrome for Developers: Chrome Headless mode

How this article was made

Researched and drafted with AI assistance from the sources listed. The benchmark (600 captures of 25 public sites in a Debian container running Chromium 155 and puppeteer-core 24.43.1) and the code sample (Puppeteer 25.16.0 on macOS) were run on 7 November 2026; the hung-process figures were read from this machine the same day.

Capture any page without ads, banners or chat widgets, free and without an account.

Try the free tools

More articles

  • News

    Puppeteer 25.19 stops print and dark mode emulation from cancelling each other

    Before Puppeteer 25.19.0, emulateMediaType and emulateMediaFeatures reset each other, losing print or dark mode. Our tests, the fix and a workaround.

    November 26, 2026
  • News

    Chrome 158 drops XSLT: what it does to screenshots of sitemaps and feeds

    We captured eight live sitemaps in Chrome 156 and Chromium 158. Styled pages turn into raw XML, a red warning bar is already in captures, and two fixes work.

    November 9, 2026
  • Research

    Chrome DevTools' full-size screenshot: where it fails on long and lazy pages

    We ran DevTools' full-size screenshot on six long pages: it stops at 16,384 pixels and misses content that appears on scroll. Here's why, and the fixes that worked.

    November 8, 2026

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

SetupTime for 100Median captureFailedCPU secondsPeak anon memoryPeak cgroup memory
One page reused, 1 at a time81 s0.67 s01421,214 MiB1,567 MiB
New context per capture, 1 at a time159 s1.18 s1249543 MiB758 MiB
New browser per capture, 1 at a time195 s1.54 s1313not split544 MiB
New context per capture, 4 at a time126 s4.40 s0251961 MiB1,158 MiB
New context per capture, 8 at a time179 s12.49 s03581,780 MiB2,188 MiB
New context, 4 at a time, full page209 s7.40 s14021,447 MiB2,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.

Line chart of memory over time during 100 screenshots. A new context per capture one at a time stays at 250 to 550 MiB, flat from 125 to 155 s during a timeout; four at a time stays at 550 to 950 MiB; one reused page swings from 750 to 1,200 MiB; eight at a time peaks at 1,780 MiB.

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;

// Puppeteer's screenshot() has no timeout option, so give every step a deadline of its own.
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(); // fresh cookies and cache per capture
  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://example.com/ 670 ms
ok   https://www.python.org/ 846 ms
ok   https://www.w3.org/ 462 ms
ok   https://go.dev/ 1079 ms

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:

  1. 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.
  2. 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.
  3. 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.