Recommended Free Tools
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
For a new Playwright deployment on AWS Lambda, use a Lambda-compatible container image that contains your handler, a pinned Playwright package, its matching Chromium browser, and the Linux libraries that browser needs. Build for the same architecture selected in Lambda. ZIP packages and layers are an option only if their combined uncompressed contents fit within Lambda’s 250 MB limit.
Playwright’s bundled Chromium is the safer default: its library and browser are separate artifacts, and Playwright does not guarantee compatibility with arbitrary Chrome or Chromium versions. This guide shows the deployment decisions, a handler pattern, how to validate the artifact, and what to check when it fails.
Choose a container image or ZIP package
A container image gives you control over the browser binary and operating-system dependencies, which is useful for a full browser automation stack. Lambda permits container images up to 10 GB uncompressed. That is a ceiling, not a target: a large image can take longer to build, pull, and become active.
| Deployment format | Size limit | What to weigh |
|---|---|---|
| ZIP function and layers | 250 MB uncompressed combined; up to five layers | Can suit a compact deployment, but browser and layer contents must be Linux-compatible and fit the shared limit. Layer files are extracted under /opt. |
| Container image | 10 GB uncompressed | Offers more room and control for browser and system dependencies. Keep it lean; unnecessary browser engines and build dependencies add size and can affect startup. |
Choose ZIP only after measuring the complete uncompressed function and all attached layers. Do not treat a browser layer as exempt from the package limit. For a container, use a multi-stage build where appropriate so build-only tools do not remain in the final image.
#1 Best Overall
Pin Playwright, browser, and architecture together
Playwright normally expects the browser revision associated with its installed package. Pin the Playwright dependency and install its browser as part of the same image build. Do not copy a browser downloaded on a different operating system and assume it will run in Lambda: the executable and its native libraries must match the Linux environment in the image.
If you specifically need branded Google Chrome or a custom Chromium binary, pin that binary too, provide its executable path to Playwright, and test the exact combination in the target image. Playwright permits an explicit executable path, but its documentation warns that compatibility with another browser version is not guaranteed. Bundled Chromium avoids that extra compatibility variable.
Keep the Lambda function architecture, image build platform, browser binary, and native modules aligned. AWS documents linux/amd64 for x86_64 and linux/arm64 for arm64 in its Node.js container instructions. Select only after confirming the browser and every native dependency you need are available for that architecture. Compare cost or performance only with the real workload; there is no universal winner based on the architecture alone.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Rank #2
Build the handler and browser into the artifact
The following handler illustrates the lifecycle your deployment needs: launch the browser, create a page, navigate, capture a screenshot, and close the browser before returning. It assumes that your image installs the pinned playwright package and a compatible Chromium executable. Set CHROMIUM_PATH to the actual path in that image; the path is image-specific.
const { chromium } = require('playwright');
exports.handler = async (event) => {
const browser = await chromium.launch({
headless: true,
...(process.env.CHROMIUM_PATH
? { executablePath: process.env.CHROMIUM_PATH }
: {})
});
try {
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } });
const url = event.url;
if (!url) throw new Error('Pass a URL in event.url');
await page.goto(url, { waitUntil: 'domcontentloaded' });
const screenshot = await page.screenshot({ type: 'png' });
return {
statusCode: 200,
headers: { 'content-type': 'image/png' },
isBase64Encoded: true,
body: screenshot.toString('base64')
};
} finally {
await browser.close();
}
};
The response shape shown is suitable for an integration that expects a base64-encoded binary body; adapt it to the event source you actually use. For larger captures, consider whether returning the whole image in the invocation response is appropriate for that integration. The example deliberately uses domcontentloaded rather than waiting for every network connection to become idle: sites with analytics, streaming requests, or long-lived connections may never reach network idle.
In the image build, install the handler, the exact pinned Playwright version, its matching browser, and all required shared libraries. The base image and installation commands must agree: Lambda’s runtime image and a general Playwright image are not interchangeable without accounting for the Lambda runtime interface and dependencies. Validate the final artifact rather than relying on a development workstation build. AWS documents building Node.js Lambda images with Buildx and the matching platform; its invocation uses --provenance=false.
Rank #3
Configure memory, timeout, and temporary storage
Lambda’s documented configuration range is 128 MB to 10,240 MB of memory, up to 900 seconds of execution time, and 512 MB to 10,240 MB for /tmp. AWS states that 1,769 MB provides the equivalent of one vCPU. These are service limits, not recommended settings for a particular browser workload.
- Memory: measure with representative pages, image dimensions, and concurrency. Browser launch and page rendering can use materially different resources on different sites.
- Timeout: include browser startup, navigation, rendering, capture, and cleanup. A longer configured timeout does not make a slow or blocked target reliable.
- Temporary storage: allow room for browser files, downloads, and screenshots your function writes. Increase
/tmpif measured peak use requires it.
Do not select settings based on a generic number from an unrelated workload. Record duration, memory use, failures, and storage use with the actual pages and invocation pattern you intend to run.
Handle temporary files and invocation reuse
/tmp belongs to an execution environment and is temporary. A warm Lambda environment may be reused, so files can remain between invocations in that environment. Cache only reusable, non-sensitive material. AWS advises against storing user data, invocation events, or security-sensitive data there.
Rank #4
Close the browser and complete background work before the handler returns. Do not launch detached tasks and assume Lambda will keep the environment alive for them. If your code writes downloads or screenshots to /tmp, use unique names or otherwise prevent one invocation from accidentally consuming another invocation’s leftover file.
Test the built image before deployment
- Build for the selected architecture. Match the Lambda setting and the browser/native modules. For AWS’s Node.js image instructions, use the corresponding Buildx platform, such as
linux/amd64orlinux/arm64, and include--provenance=falsein the documented build invocation. - Run the final image locally with Lambda’s runtime interface emulator. AWS provides an emulator for local image checks. Use it to verify the handler can be invoked in a Lambda-compatible container context.
- Check browser startup and shared libraries. Launch Chromium in the final image, navigate to a representative page, and capture an image. A browser executable that exists but cannot load a shared library is not a working deployment.
- Exercise storage and cleanup. Test the largest expected screenshot or download, confirm it fits configured storage, and verify the browser process closes on success and on errors.
- Deploy and test real conditions. Local success does not establish production networking, target-site behavior, or concurrency capacity. Verify those in the deployed environment with the pages and invocation pattern you need.
Common deployment failures and fixes
| Symptom | Likely cause | What to check or change |
|---|---|---|
| Browser executable missing | The Playwright package is installed but its browser was not included, or the configured path is wrong. | Install the expected browser during the image build. If using a custom binary, set CHROMIUM_PATH to the path inside the final image and test that exact path. |
| Shared library or launch error | Required Linux libraries are absent or do not match the browser build. | Build and install dependencies for the target Lambda Linux image; test browser launch in the final artifact, not only on a developer machine. |
| Browser works locally but not in Lambda | Architecture, operating system, or native dependencies differ between local and deployed environments. | Align the image platform, Lambda architecture, browser, and native modules. Rebuild for the target platform and validate with the Lambda runtime interface emulator. |
| ZIP deployment exceeds its limit | The function and attached layers exceed the shared 250 MB uncompressed quota. | Measure the uncompressed total, remove unnecessary files, or move to a container image. Layers count toward the same quota. |
| Navigation times out | The target is slow, unreachable from the function, or keeps network activity open. | Test target connectivity and choose a navigation condition suitable for the page. Set timeout based on measured workload; do not wait for network idle when persistent requests prevent it. |
| Invocation runs out of time or storage | The page, capture, or download exceeds configured resources. | Measure the real page and artifact size, then adjust memory, timeout, or /tmp within Lambda’s documented limits. Reduce unnecessary capture or download work. |
| Custom Chrome behaves differently | The browser version is not compatible with the pinned Playwright package. | Pin both components and validate their combination in the target image, or use the Chromium revision expected by Playwright. |
Performance, reliability, and cost considerations
Container images make the browser stack easier to define, but a permitted 10 GB image can still create build, pull, and startup costs in time. Keep only the browser engine and runtime libraries the function uses. A multi-stage build can separate compilation or other build-only work from the runtime image.
Browser startup and page rendering depend on page complexity, network conditions, memory, architecture, and concurrency. The available documentation does not establish a universal memory recommendation, cold-start duration, or throughput for Playwright on Lambda. Benchmark the artifact and pages you will actually run, including concurrent invocations and failure cases. Likewise, an emulator check is a useful packaging test, not proof of production network access or target-site compatibility.
Best Value
Playwright browser downloads use hundreds of megabytes of disk space, so a browser deployment should be treated as a substantial dependency rather than a small function add-on. For teams already comfortable with Docker and ECR, the image path offers reproducible control; a ZIP path may be acceptable if the full size and dependency constraints are demonstrably met.
Or skip the browser setup
If your goal is to get website screenshots rather than operate a browser runtime, ScreenshotNeo offers a screenshot API and MCP server. A single GET request returns an image or PDF; the API supports PNG, JPEG, or WebP screenshots and PDF output.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for parameters and response details. Cookie banners and consent overlays, newsletter popups, and chat widgets can be removed before capture, with each cleanup step configurable. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; responses include X-Page-Verdict and X-Billed headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteThe Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. If that fits your use case, sign up for ScreenshotNeo.
Frequently Asked Questions
Can I use a Playwright package such as playwright-aws-lambda as a shortcut?
A package’s own stated runtime support is not the same as current AWS compatibility certification. Check its maintenance and test its exact browser, architecture, and runtime combination in your Lambda image before depending on it.
Does a successful local emulator test prove my target website will work in Lambda?
No. It checks aspects of the image and handler in a Lambda-compatible context, but production network access, the target site’s behavior, and concurrency still need validation in the deployed environment.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →

