Browser pool: pre-warm Chromium instances to eliminate cold-start latency on search #47

Closed
opened 2026-04-20 08:50:40 -07:00 by pyr0ball · 0 comments
Owner

Problem

Each /api/search request cold-starts a new Chromium instance to bypass Kasada. Under load this means 10-30s of browser startup before any eBay content is fetched. Spike #5 showed p50 of 29s on search — startup overhead is the dominant cost.

Proposed Fix

Maintain a pool of N pre-warmed Chromium/Playwright browser contexts (suggested N=2-3). Each search request borrows a context from the pool, navigates and scrapes, then returns the context (not closes it).

  • Pool initialized at startup, replenished after each use
  • Idle timeout to close contexts if unused for >5 min (avoid memory bloat)
  • Pool size configurable via BROWSER_POOL_SIZE env var (default 2)
  • Fallback: spin up a fresh browser if pool is empty (current behavior)

Expected Impact

  • p50 search latency: 29s → ~3-5s (Kasada negotiation only, no cold start)
  • Enables meaningful concurrency without N×browser memory overhead

Notes

  • Playwright browser contexts are lightweight vs full browser instances — pool the context, not the browser
  • Kasada state may need to be preserved per-context (cookies, fingerprint) — test whether context reuse maintains bypass
## Problem Each `/api/search` request cold-starts a new Chromium instance to bypass Kasada. Under load this means 10-30s of browser startup before any eBay content is fetched. Spike #5 showed p50 of 29s on search — startup overhead is the dominant cost. ## Proposed Fix Maintain a pool of N pre-warmed Chromium/Playwright browser contexts (suggested N=2-3). Each search request borrows a context from the pool, navigates and scrapes, then returns the context (not closes it). - Pool initialized at startup, replenished after each use - Idle timeout to close contexts if unused for >5 min (avoid memory bloat) - Pool size configurable via `BROWSER_POOL_SIZE` env var (default 2) - Fallback: spin up a fresh browser if pool is empty (current behavior) ## Expected Impact - p50 search latency: 29s → ~3-5s (Kasada negotiation only, no cold start) - Enables meaningful concurrency without N×browser memory overhead ## Notes - Playwright browser contexts are lightweight vs full browser instances — pool the context, not the browser - Kasada state may need to be preserved per-context (cookies, fingerprint) — test whether context reuse maintains bypass
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/snipe#47
No description provided.