Puppeteer vs PDF API: Performance and Cost Compared
Puppeteer works well at low volumes. At scale, the operational overhead — memory management, browser version management, browser pool complexity — starts to dominate engineering time. A managed PDF API trades that overhead for a monthly subscription.
This article compares the two approaches across dimensions that matter for production systems: performance, memory, concurrency, cost, and operational complexity. Because the numbers depend heavily on your workload and environment, this article does not quote fixed figures; it focuses on what to measure and compare. If you have already decided to migrate and want step-by-step code, see the Puppeteer to PDF API migration guide.
What Each Approach Actually Involves
Self-Hosted Puppeteer
The Puppeteer docs describe it this way: "Puppeteer is a JavaScript library which provides a high-level API to control Chrome or Firefox", and it runs headless (no visible UI) by default. To use it for PDF generation in production you need to:
- Manage the browser version and update and re-test it when security fixes ship
- Build and maintain a browser pool to avoid paying the browser launch cost per request
- Handle memory limits, zombie processes, and graceful restarts
- Include Chrome in your Docker images (per the docs, the Chrome for Testing that
npm i puppeteerdownloads is about 282MB on Linux) - Manage browser downloads and caching in CI/CD
None of these tasks are related to generating PDFs. They are the cost of running a browser in production.
Managed PDF API
A managed PDF API (such as FUNBREW PDF) accepts HTML over HTTP and generates a PDF; you then fetch the PDF from the download_url in the JSON response. There is no Chrome on your servers. Engine upgrades and the rendering infrastructure are run by the service, and you can send requests in parallel up to your plan's per-minute limit.
The decision comes down to whether the engineering time saved by offloading browser operations outweighs the monthly cost of the API.
Performance Comparison
Response Time
Response time depends heavily on HTML size, image and font fetches, CSS complexity, and the runtime environment. When comparing, measure the following with your own representative templates.
| What to measure | Self-hosted Puppeteer | Managed PDF API |
|---|---|---|
| Browser launch | Paid each time a process starts (a pool avoids it) | Not paid on your side |
| Page rendering | Runs on your server's CPU and memory | Runs on the API side |
| Network | None | Round trip to the API, plus fetching the PDF from download_url |
In serverless environments the browser has to start in each function execution environment, so Puppeteer's launch cost is especially visible. With a managed API your function no longer launches a browser, but the API call and the PDF download still take time. For Lambda-specific deployment, see the serverless PDF API guide.
Memory Usage
With Puppeteer, the browser processes and the memory for each open page live on your server. Memory grows with the number of pages you render at once, so you end up sizing the browser pool from the server's memory.
With a managed API, your server only holds the HTTP client and the buffer for the PDF you download.
Both depend on your environment, so measure process memory (RSS) with your own templates at different concurrency levels.
Docker Image Size
# Puppeteer image
FROM node:22
# Install the shared libraries Chrome needs with apt (use the Dockerfile from the official Puppeteer Docker guide as a starting point)
RUN npm install puppeteer # also downloads Chrome for Testing
# API client image
FROM node:22-alpine
# No Chrome required
A Puppeteer image adds Chrome itself (about 282MB on Linux) plus the shared libraries it needs. Check the real difference by comparing both images with docker images. A smaller image means faster CI builds, faster image push/pull, and faster container startup. Node.js 20 reached end of life in March 2026, so the examples use Node.js 22. For container deployment patterns, see the Docker and Kubernetes PDF API guide.
Concurrency
Puppeteer (your server):
Ceiling: set by your server's memory and CPU
Beyond that: queue, or crash on out-of-memory
FUNBREW PDF API:
Ceiling: your plan's requests per minute (Free 10 / Pro 120 / Business 300)
Beyond that: HTTP 429 with a Retry-After header
Monthly cap: 429 once the plan's monthly PDF count is used up (waiting does not clear it)
If you need to generate many PDFs at once, Puppeteer requires either a large instance or a distributed setup. With the managed API you can send requests in parallel within your plan's per-minute limit.
Cost Comparison
Self-Hosted Costs
Infrastructure
You need a server with enough memory for both the browser pool and your application (or a dedicated PDF server). Burst traffic calls for a larger instance or auto-scaling. Check current prices on your cloud provider's pricing page.
Engineering and Maintenance
To estimate, add up the following from your own history:
- Initial implementation (browser pool, timeouts, retries)
- Browser version updates, and re-checking output each time
- Incident response (out-of-memory, zombie processes)
- Managing browser downloads and caching in CI
CI/CD
Browser downloads slow builds, and large Docker images increase push/pull times and registry storage. These are small individually but compound across a large team.
Managed API Costs
FUNBREW PDF free plan: 30 PDFs/month at no cost
Paid plans: fixed monthly price with a monthly PDF limit (Pro 1,000 / Business 10,000)
Pricing: see /#pricing
Engineering cost: implementing the API client and checking template output
How to Think About Break-Even
| Situation | Usually favours | Why |
|---|---|---|
| Low volume, PDFs are a minor feature | Managed API | The fixed cost of running a browser (build, updates, incidents) is heavy relative to the volume |
| Medium volume | Depends on your estimate | Compare server cost plus maintenance hours with the matching plan's monthly price |
| High volume (beyond the top plan's monthly limit) | Consider self-hosting too | First check whether you fit within the monthly and per-minute limits |
The cost most teams undercount is engineer opportunity cost. Every hour spent managing a browser is an hour not spent on the product.
Operations Comparison
| Dimension | Puppeteer (self-hosted) | Managed PDF API |
|---|---|---|
| Browser upgrades | Manage versions; re-check output on every update | Not your concern |
| Security fixes | Update the browser yourself | Handled by provider |
| Scaling concurrency | Manual pool tuning or infra scaling | Parallel up to the plan's per-minute limit (429 beyond it) |
| Monitoring | Browser health, memory, zombie processes | HTTP error rates, 429s, monthly usage |
| Serverless | Need to deal with the package size of a bundled browser | Only an HTTP client |
| Docker image | Larger by Chrome plus shared libraries | Lightweight (no Chrome) |
| On-call incidents | Out-of-memory crashes, process leaks | HTTP 5xx from provider, hitting limits |
For a deeper look at security considerations when self-hosting a browser, see the PDF API security guide.
CSS and Rendering Compatibility
FUNBREW PDF has two engines: quality is Chromium (Gotenberg) and fast is wkhtmltopdf. For output close to Puppeteer, set options.engine to quality (Pro plan or above; Free gets a 403). Even between Chromium-based renderers the version and settings differ, so compare output with your own templates before migrating.
Points to check when evaluating:
- Media type: Puppeteer's
page.pdf()usesprintmedia by default (docs: "Generates a PDF of the page with theprintCSS media type."). The API has no media type option, so if you calledpage.emulateMediaType('screen')in Puppeteer, move your@media screenstyles over to print. page.evaluate()DOM manipulation: The API has no equivalent ofpage.evaluate(). Move that logic into the template rendering step that builds the HTML.- PDF options: The API accepts only
page-size(A3, A4, A5, Letter, Legal),orientation,margin-top/right/bottom/left(mm, 0 to 50) andengine. Puppeteer names such asprintBackground,preferCSSPageSizeorheaderTemplateare silently ignored.
For detailed CSS tips during migration, see HTML to PDF CSS tips.
How to Decide
Use the lists below to choose the right approach for your situation.
Use Self-Hosted Puppeteer If
- You are prototyping, the volume is low, and running the browser is not yet a burden
- Your security policy prohibits sending HTML to external services
- You need
page.evaluate()to run complex JavaScript before generating the PDF (and cannot move that logic to server-side rendering) - You need PDF options the API does not have, such as custom paper sizes or header/footer templates
- You are already heavily invested in Puppeteer for browser testing, and PDF generation is a minor feature
Use a Managed PDF API If
- PDF generation is a non-trivial part of your product
- You do not want to bundle a browser in your serverless functions
- Your Puppeteer setup is already causing out-of-memory crashes, browser upgrade breakages, or CI/CD slowdowns
- You want to keep Docker images lean
- Your volume fits within a plan's monthly and per-minute limits
The Gradual Migration Path
You do not have to migrate all at once. A common pattern is to introduce a wrapper function:
// Thin wrapper — start by calling Puppeteer
async function generatePdf(html, options = {}) {
// Phase 1: Puppeteer
return generatePdfWithPuppeteer(html, options);
// Phase 2: flip to API when ready
// return generatePdfWithApi(html, options);
}
Migrate one PDF type at a time (invoices first, then reports, then certificates), using a feature flag to control the cutover. This gives you a rollback path while the team builds confidence in the API output. See the full migration procedure in the Puppeteer to PDF API migration guide.
Quick-Start Code
If you decide to try the API, here is a minimal Node.js (18+) example. The generation API returns JSON, so fetch the PDF from data.download_url with the same API key.
const BASE_URL = 'https://pdf.funbrew.cloud';
async function generatePdf(html) {
const headers = { Authorization: `Bearer ${process.env.FUNBREW_PDF_API_KEY}` };
const response = await fetch(`${BASE_URL}/api/pdf/generate-from-html`, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({
html,
options: {
'page-size': 'A4',
'margin-top': 20,
'margin-bottom': 20,
'margin-left': 15,
'margin-right': 15,
engine: 'quality', // Chromium; Pro plan or above
},
}),
});
if (!response.ok) throw new Error(`API error: ${response.status}`);
const { data } = await response.json();
const pdf = await fetch(data.download_url, { headers });
if (!pdf.ok) throw new Error(`Download error: ${pdf.status}`);
return Buffer.from(await pdf.arrayBuffer());
}
Test your HTML in the Playground before writing any code (the Playground always renders with the quality engine and adds a TEST watermark). The free plan gives you 30 PDFs/month at no cost. For Python, PHP, Ruby, and Go examples, see the API quickstart by language.
Summary
| Puppeteer (self-hosted) | Managed PDF API | |
|---|---|---|
| Browser launch | Paid on your server (a pool avoids it) | Not paid on your server |
| Memory on your server | Browser and pages | HTTP client and the PDF buffer only |
| Docker image | Larger by Chrome plus shared libraries | Lightweight |
| Concurrency ceiling | Server memory and CPU bound | Plan's per-minute limit |
| Maintenance | Ongoing browser updates and incidents | Maintaining the API client |
| Cost | Server plus engineer hours | Starts free; paid plans are fixed monthly |
Puppeteer is a reasonable starting point. Once PDF generation becomes a real production workload and running the browser becomes a visible burden, a managed PDF API is a strong option. Try the Playground to verify output quality against your templates before committing.
Related
- Puppeteer to PDF API Migration Guide — Step-by-step migration with before/after code
- HTML to PDF API Comparison 2026 — Broader comparison including wkhtmltopdf and Gotenberg
- PDF API Quickstart by Language — Node.js, Python, PHP, Ruby, Go examples
- Serverless PDF API Guide — Lambda and Cloudflare Workers deployment
- Docker and Kubernetes PDF API Guide — Container-based deployment patterns
- PDF API Error Handling Guide — Retry logic and resilience patterns
- PDF API Security Guide — Security best practices for PDF generation