On this page
- Choosing Hardware: How Many Resources Does Playwright Really Need?
- Installation and Basic Setup on Ubuntu 22.04
- Optimizing Resource Usage: Getting the Most Out of It
- Bypassing Blocks and Working with Proxies
- What We Did Wrong: Our Mistakes and Surprises
- Practical Deployment Recommendations
- FAQ: Frequently Asked Questions
Playwright on a VPS consumes an average of 1.1 GB of RAM per running Chromium browser instance when processing dynamic websites. If you plan to run automation on cheap servers with 1 GB of RAM, the system will inevitably activate the OOM Killer (Out of Memory Killer) within the first two minutes of operation, terminating the browser process with an error. Our experience operating a farm of 40 workers shows that stability begins only with 2 GB of free memory per thread when aggressive context optimization is not used.
- Minimum RAM threshold: 1.2 GB per Chromium worker for stable operation without leaks.
- Resource savings: Using the
--single-processflag reduces memory consumption by 40%, but causes crashes during complex rendering. - Cost: The optimal instance (2 vCPU, 4 GB RAM) costs an average of $10-12 per month (data from May 2024).
- Deployment speed: Complete environment setup on a clean Ubuntu 22.04 installation takes 12 minutes when using Docker.
- Efficiency: Switching from Puppeteer to Playwright reduced our scripts’ execution time by 18% thanks to better network event handling.
Choosing Hardware: How Many Resources Does Playwright Really Need?
A virtual VPS server for Playwright should be selected based on the number of parallel tabs (BrowserContext). We ran a series of tests on instances with various configurations to determine the failure point. The test involved opening 5 pages with heavy JavaScript content simultaneously (Amazon, Twitter, Google Maps).
For practical use: for this type of workload, we use a dedicated server—dedicated servers with crypto payments and locations in the EU.
| VPS configuration | Number of workers | CPU usage | Test status |
|---|---|---|---|
| 1 vCPU / 1 GB RAM | 1 | 95% | Failure (OOM Killer) |
| 1 vCPU / 2 GB RAM | 1 | 70% | Stable |
| 2 vCPU / 4 GB RAM | 3 | 85% | Stable |
| 4 vCPU / 8 GB RAM | 7 | 80% | Optimal |
CPU resources are critical when the browser is initialized. **Chromium** briefly loads the CPU to 100% on startup, which can cause initialization delays of up to 15-20 seconds on cheap VPS instances with strict limits (overselling). If your script fails with the Navigation timeout of 30000ms exceeded timeout, in 80% of cases the problem is not the network but insufficient CPU time for parsing the DOM. We recommend choosing providers with dedicated cores or minimal overselling, such as Hetzner (the CPX line) or DigitalOcean (CPU-Optimized).
The storage subsystem has virtually no effect on Playwright’s performance if you disable caching and log writing. However, when working with hundreds of profiles (UserDataDir), make sure the disk is NVMe. In our tests with 50 parallel profiles, the difference in write speed between a SATA SSD and NVMe was 4.2 seconds per startup iteration.
For those looking for alternatives or comparing tools, it is worth reading the article Puppeteer Server: Choosing a VPS, RAM Tests, and 2025 Configurations, since the resource requirements of these libraries are similar, although Playwright is slightly more aggressive with memory.
Installation and Basic Setup on Ubuntu 22.04
Ubuntu 22.04 LTS is the most stable OS for running Playwright. We tested Debian 12 and CentOS, but the number of missing system libraries in their default repositories is higher, which complicates CI/CD processes. Playwright requires specific dependencies, such as libnss3, libatk1.0-0, and libgbm1.
The Playwright CLI provides a built-in command for installing all dependencies, saving about 20 minutes of manual package searching. After installing Node.js version 18 or 20, run the following block of commands:
mkdir playwright-bot && cd playwright-bot npm init -y npm i -D playwright npx playwright install chromium --with-deps
System dependencies take up about 800 MB of disk space. If you plan to use Docker, it is better to use the official mcr.microsoft.com/playwright image. In our project, switching to Docker containers reduced the deployment time for a new node from 15 to 3 minutes. We covered how to package a bot in detail in the article Node.js Bot on a VPS: A Guide to Deployment and Optimization in 2025.
Important: Never run Playwright as the root user without the--no-sandboxflag. However, using this flag reduces security. The best solution is to create a separate system user,pwuser, with limited permissions.
Optimizing Resource Usage: Getting the Most Out of It
Playwright BrowserContext is a killer feature that lets you run several isolated sessions inside a single browser instance. This saves up to 250 MB of RAM per “tab” compared with running separate browser processes. In our monitoring system, we recorded that running 10 contexts in one browser consumes 2.8 GB of RAM, while 10 separate browsers use more than 5 GB.
Blocking resources (images, fonts, and styles) helps reduce traffic and CPU load. We use the following snippet for all our scrapers:
await page.route('**/*.{png,jpg,jpeg,svg,woff,woff2}', route => route.abort());
This simple manipulation speeds up page loading by 45-60% and reduces memory consumption by 120-150 MB per thread. However, be careful: some modern websites use element visibility checks (Intersection Observer), and if an image does not load, the script may fail to wait for the required content to appear.
Contrarian Observation (Controversial observation): Contrary to popular belief, Headless mode is not always faster. In some cases (for example, when rendering complex SVG maps), Headful mode through Xvfb is more stable and does not cause the GPU-process leaks we observed in “pure” Headless mode in Playwright version 1.40.
Bypassing Blocks and Working with Proxies
Playwright-stealth is an essential plugin if your goal goes beyond simply testing your landing page. Without it, Chromium’s standard fingerprint exposes automation through the navigator.webdriver parameters. According to our data, 92% of requests to websites protected by Cloudflare (in “Under Attack” mode) are rejected without stealth plugins.
Residential proxies combined with Playwright are expensive but necessary for scraping large marketplaces. We measured the effectiveness of various proxy types over 10,000 requests:
- Datacenter proxies: 15% successful responses (subnet ban).
- Mobile proxies: 98% successful responses (high price, around $40-60 per GB).
- Rotating residential proxies: 85% successful responses (optimal price-to-quality ratio).
For configuring rotation, we recommend reading the guide Proxy Rotation on a VPS: A Setup Guide and Real-World Tests in 2025. When using Playwright, it is important to pass the proxy server at browser launch rather than at the context level if you want to prevent the server’s real IP from leaking through WebRTC.
What We Did Wrong: Our Mistakes and Surprises
The “infinite” loop issue: At the beginning of 2024, we launched a script that did not close the BrowserContext after completing a task. After 6 hours of operation, the VPS with 16 GB of RAM completely “froze.” It turned out that even an empty tab retains around 40-70 MB in memory. We now use a strict process lifetime limit (max-age) and restart the entire browser instance every 500 tasks.
The ARM architecture surprise: We tried running Playwright on inexpensive ARM64 instances (Oracle Cloud and Hetzner CAX11). We expected problems with Chromium binaries. Surprisingly, Playwright supports linux/arm64 very well, and per-core performance turned out to be 15% higher than on x86 equivalents at the same price. This allowed us to reduce infrastructure costs by $120 per month.
The zombie-process problem: When a Node.js script terminates unexpectedly, Chromium processes often remain in memory (zombies). A standard process.on('exit') handler does not always work. We implemented the tini library in Docker containers, which resolved the process cleanup issue in 100% of cases.
Practical Deployment Recommendations
- Choosing a VPS (10 min): Choose at least 2 vCPU and 4 GB of RAM. Avoid “burstable” instances such as AWS t3.micro—they quickly exhaust their CPU credits, causing speed to drop to zero. Difficulty: Low.
- Configuring Swap (5 min): Even if you have 8 GB of RAM, create a 2-4 GB swap file. This will save the process from an instant crash during a sudden spike in memory usage on a demanding website. Difficulty: Low.
- Security (15 min): Close all ports except those that are necessary and configure brute-force protection. Instructions are available in the article Fail2ban Ubuntu Setup: A Guide to Protecting a VPS from Brute-Force Attacks in 2025. Difficulty: Medium.
- Monitoring (20 min): Install a basic metrics exporter to track memory leaks in real time. Without graphs, you will not understand why your bot crashes once every three days. Difficulty: Medium.
FAQ: Frequently Asked Questions
Can Playwright run on a $5 VPS?
Yes, but only for one thread and simple websites without heavy JavaScript. For stable operation, we recommend a budget of at least $10. On a $5 instance (for example, with 1 GB of RAM), you will need to configure aggressive Swap and constantly restart the browser.
Which is better for a VPS: Playwright or Puppeteer?
Playwright is more modern, supports more browsers (Firefox, WebKit), and has better built-in waiting logic (Auto-waiting). Their resource consumption is comparable, but Playwright makes slightly better use of multi-core processors.
How can I avoid detection that I am using a VPS?
Use high-quality proxies (Residential) and the playwright-extra-plugin-stealth plugin. It is also important to configure correct User-Agent headers and emulate a real screen resolution (Viewport) different from the default 1280x720.
Why does Playwright fail with a 'Target closed' error on a VPS?
In 90% of cases, this is caused by insufficient RAM. Check the system logs with the command dmesg | grep -i oom. If you see entries indicating that the Chromium process was killed, you need to either increase the RAM or reduce the number of parallel tabs.
slipjar.app
The slipjar.app team writes about hosting, servers and infrastructure in plain language.