HeadlessX icon indicating copy to clipboard operation
HeadlessX copied to clipboard

Slowness of v2 beta

Open emadmahdi opened this issue 10 months ago • 19 comments

Same slow problem with v2 beta .. Fetching html for https://example.com takes 25-35 seconds .. I installed it fresh after you publish the new fixes.

I used this curl command for testing .. I tried both stealth enabled & disabled:

curl -X POST http://my.vps.ip:3001/api/website/html \
  -H "Content-Type: application/json" \
  -H "X-API-Key: hx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -d '{"url": "https://example.com", "stealth": false}'

emadmahdi avatar Jan 29 '26 06:01 emadmahdi

Thanks for the detailed report and the curl command.

Since v2.0 switches to the Camoufox engine (which is heavier than the standard Puppeteer/Playwright setup used in v1), some initial startup latency is expected, especially on the very first request if the browser instance is cold-booting.

I'll investigate if we can optimize the browser instance pooling to keep it 'warm' longer and reduce that initial hit

saifyxpro avatar Jan 29 '26 06:01 saifyxpro

This delay is expected behavior for fresh sessions in v2.0.

Because we moved to Camoufox, the browser engine is significantly heavier and more complex than standard automation updates. When you run a request without a profile (fresh session), the system has to fully launch a new, isolated browser process from scratch, which takes time to initialize the stealth components.

The Solution: If you use a persistent profile (by effectively 'keeping it open' or reusing a session), the response will be much faster because the browser process is already running in the background.

We designed v2 primarily for stealth and persistence rather than raw speed for one-off throwaway requests. I recommend trying it with a saved profile to see the performance difference.

saifyxpro avatar Jan 29 '26 06:01 saifyxpro

I highly recommend trying out the Dashboard/Frontend. It makes it much easier to understand how the sessions work and gives you a visual way to manage your scraping profiles.

saifyxpro avatar Jan 29 '26 06:01 saifyxpro

I have applied the Performance Fix to ScraperService.ts.

Change Summary:

The scraper now strictly respects the stealth: false parameter. When stealth: false is detected, it enters "Speed Mode", skipping all human-like mouse movements and scrolling. This removes the artificial delay (approx. 20-30s) that was previously occurring even when stealth was disabled.

saifyxpro avatar Jan 30 '26 05:01 saifyxpro

I will update and test both; stealth and profiles then will get back to you. Thank you

emadmahdi avatar Jan 30 '26 09:01 emadmahdi

i did fresh install but using old database .. here is the results:

stealth: false .. same problem

1st request: 28s 2nd request: 26s 3r request: 27s

curl -X POST http://myip:3001/api/website/html -H "Content-Type: application/json" -H "X-API-Key: hx_myapikey" -d '{"url": "http://example.com", "stealth": false}'

=============================

stealth: true .. same problem

1st request: 27s 2nd request: 27s 3r request: 26s

curl -X POST http://myip:3001/api/website/html -H "Content-Type: application/json" -H "X-API-Key: hx_myapikey" -d '{"url": "http://example.com", "stealth": true}'

=============================

profile: default .. got error message .. profile created and started using frontend .. and also created using API .. both profiles failed with the same error message

curl -X POST http://localhost:3000/api/profiles 
  -H "Content-Type: application/json" 
  -d '{"name": "default"}'

curl -X POST http://myip:3001/api/website/html
-H "Content-Type: application/json"
-H "X-API-Key: hx_myapikey"
-d '{"url": "http://example.com", "profileId": "default", "stealth": false}'`

.

{"success":false,"error":{"code":"SCRAPE_FAILED","message":"Profile not found: default"}}

emadmahdi avatar Jan 31 '26 00:01 emadmahdi

As for trying the frontend .. i always get this error screen:

. .

====

Image

emadmahdi avatar Jan 31 '26 00:01 emadmahdi

also some nice database errors:

. .

=====================

[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[0] 🦊 Launching Camoufox (Headless: true, Profile: default, Proxy: Disabled)
[0] ✅ Camoufox launched (anti-fingerprint active)
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58
[0]
[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58
[0]
[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58
[0]
[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58
[0]
[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58
[0]
[0]   73
[0]   74 try {
[0]   75     // Try fetch from DB
[0] → 76     const dbConfig = await prisma.systemSettings.findUnique(
[0] The column `(not available)` does not exist in the current database.
[1] ○ Compiling /profiles ...
[1]  GET /profiles 200 in 10.5s (compile: 10.3s, render: 215ms)
[1]  GET /profiles 200 in 182ms (compile: 15ms, render: 167ms)
[0] ⚠️ ConfigService: DB connection failed, using Env defaults.
[0] Invalid `prisma.systemSettings.findUnique()` invocation in
[0] /home/headlessx/HeadlessX/backend/src/services/ConfigService.ts:76:58

emadmahdi avatar Jan 31 '26 00:01 emadmahdi

And the profile is created successfully:

. .

============

Image

emadmahdi avatar Jan 31 '26 00:01 emadmahdi

how come this issue is closed ?!!!!!

emadmahdi avatar Jan 31 '26 00:01 emadmahdi

i updated the database schema using "pnpm push" and it finished successfully but profile error still same.

curl -X POST http://myip:3001/api/website/html
-H "Content-Type: application/json"
-H "X-API-Key: mykey"
-d '{"url": "http://example.com", "profileId": "default", "stealth": false}'

{"success":false,"error":{"code":"SCRAPE_FAILED","message":"Profile not found: default"}}

emadmahdi avatar Jan 31 '26 01:01 emadmahdi

Let me Share the Proofs, Kindly Update

saifyxpro avatar Jan 31 '26 10:01 saifyxpro

Performance Fix - v2.0.1 Update Required

✅ Issue Resolved

We've identified and fixed the performance issues causing slow scraping times. The fix significantly improves speed when using persistent profiles with stealth mode disabled.

📦 Update Instructions

cd HeadlessX

# Pull latest changes
git pull origin main

# Backend
cd backend
pnpm install
pnpm exec prisma generate  # Regenerate Prisma client
pnpm exec prisma db push   # Sync database schema

⚡ Performance Results

Before Fix

  • ~25-35 seconds per request

After Fix

Mode Time
API with profile + stealth OFF 1.7s
Frontend with profile + stealth OFF 2.8s
First request (cold start) ~15-20s

🔧 How to Get Maximum Speed

1. Create & Launch a Profile

Go to Profiles page → Create a profile → Click Launch to start the browser

2. Disable Stealth Mode

In the Website Scraper, expand Advanced Config and toggle OFF Stealth Mode

Image

3. API Usage

Pass stealth: false in options for fastest scraping:

curl -X POST http://localhost:3001/api/website/html \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "url": "https://example.com",
    "profileId": "your-profile-name",
    "options": { "stealth": false }
  }'

Response (1.7s):

{
  "url": "https://example.com",
  "html": "<!DOCTYPE html>...",
  "stats": { "duration": 1767, "statusCode": 200 }
}

Note: First request after launching a profile will still take ~15-20s (Camoufox initialization). Subsequent requests will be under 3 seconds.

Let me know if you have any questions! 🎉

saifyxpro avatar Jan 31 '26 12:01 saifyxpro

Same slowness: 25 seconds. Same frontend problem.

emadmahdi avatar Feb 14 '26 01:02 emadmahdi

I think you are overloading my vps server .. that is why it is slow .. you are using too much cpu/ram .. and this is wrong.

I am using botasaurus python package with camoufox browser and it is quick and does not overload my cpu/ram .. i am using both headed and headless browsers and both are fast .. it is installed on the same vps server of HeadlessX.

The images show the usage of CPU and RAM for both HeadlessX and Botasaurus.

.

HEADLESSX Performance for 1 not blocked request "http://example.com/" .. When request finished usage is: 32% CPU + 1.97GB RAM

Image

.

BOTASAURUS Performance for 1 cloudflare blocked request "https://asd.pics/" .. When request finished usage is: 1% CPU + 0.5GB RAM

Image

emadmahdi avatar Feb 14 '26 02:02 emadmahdi

This is Botasaurus: https://github.com/omkarcloud/botasaurus

I suggest you use it as a backend instead of yours .. or make it optional.

emadmahdi avatar Feb 14 '26 02:02 emadmahdi

Ok, Let me Check

saifyxpro avatar Feb 14 '26 04:02 saifyxpro

Thanks for the detailed report and the screenshots.

You are right to call out the current CPU and RAM usage. That level of overhead for a simple request is not acceptable, and I am actively working on improving it.

About Botasaurus: I know the project. It is built around Chromium / Playwright-style automation with JavaScript-layer patching. That approach can be fast, but it is still patching at the JS/runtime layer, which means it can still be detected by stronger anti-bot systems. So I do not want to switch HeadlessX to that model as the main backend.

My direction is different:

  • custom Firefox 148 base
  • deeper C++-level patching instead of only JS patching
  • better stealth for harder targets
  • lower resource usage and better runtime optimization
  • more agent-friendly workflows through the CLI and Agent Skills

So yes, performance optimization is a real priority, and I am already working on it. The goal is not only to make HeadlessX faster and lighter, but also to keep the stronger browser-level stealth model instead of falling back to a Chromium + JS-patched approach.

In short:

  • your performance complaint is valid
  • I am not ignoring it
  • I do not want to replace the backend with Botasaurus
  • I am working on a newer optimized custom Firefox 148 path that should be both stealthier and more efficient

saifyxpro avatar Mar 20 '26 15:03 saifyxpro

A new Firefox-based browser called Headfox is coming soon, built on the latest Firefox 148. It is the direction I am actively working on for better stealth, better optimization, and a stronger long-term backend for HeadlessX.

saifyxpro avatar Mar 20 '26 15:03 saifyxpro