The headless browser for AI agents and web scraping
docs: document worker recycling options
flolep2607e71d6dd55939
diff --git a/README.md b/README.mdindex 8e16b915..5a704ae0 100644--- a/README.md+++ b/README.md@@ -472,12 +472,21 @@ Start a CDP WebSocket server.| `--proxy` | — | HTTP/SOCKS5 proxy URL || `--stealth` | off | Enable anti-detection + tracker blocking || `--workers` | `1` | Number of parallel worker processes |+| `--worker-max-connections` | off | Recycle a worker after N CDP connections (needs `--workers` > 1) |+| `--worker-max-rss` | off | Recycle a worker above this many MB resident (Linux) |+| `--worker-max-age` | off | Recycle a worker after this many seconds |+| `--worker-drain-timeout` | `120` | Seconds a replaced worker may finish its live connections before it is killed || `--font-dir` | — | Recursively load fonts once per worker (repeatable; render build) || `--obey-robots` | off | Respect robots.txt |With multiple workers, exited children are reaped and restarted. New connectionsuse ready workers only; if none are ready, the balancer returns HTTP 503. A crashstill closes that worker's existing sessions, which clients must reconnect.++The `--worker-max-*` options recycle workers gracefully: a replacement starts+first, new connections go only to it, and the old worker keeps serving the+connections it already has until they close (or the drain timeout passes), then+exits. Each recycle is logged with its reason.Worker errors remain visible on stderr.### `obscura fetch <URL>`diff --git a/docs/CLI-reference.md b/docs/CLI-reference.mdindex 90b7699a..ea58b87a 100644--- a/docs/CLI-reference.md+++ b/docs/CLI-reference.md@@ -70,6 +70,10 @@ Run the CDP server. Puppeteer and Playwright connect over WebSocket.--user-agent <UA> Override the User-Agent--stealth Consistent browser fingerprint + tracker blocking (global)--workers <N> Worker processes (default 1)+ --worker-max-connections <N> Recycle a worker after N CDP connections (--workers > 1)+ --worker-max-rss <MB> Recycle a worker above this resident size (Linux)+ --worker-max-age <SECS> Recycle a worker after this long+ --worker-drain-timeout <SECS> Let a replaced worker finish live connections (default 120)--font-dir <DIR> Recursively load fonts once per worker (repeatable; render build)--allow-file-access Permit CDP clients to navigate to file:// URLs--storage-dir <DIR> Persistent cookies and localStoragediff --git a/docs/Run-in-production-at-scale.md b/docs/Run-in-production-at-scale.mdindex c3d8ece5..199828e1 100644--- a/docs/Run-in-production-at-scale.md+++ b/docs/Run-in-production-at-scale.md@@ -84,6 +84,12 @@ obscura serve --workers 4Use one worker per CPU core. Each worker handles its own pool of pages. Sessions are sticky to a worker.+Worker memory can grow over days. Recycle workers with `--worker-max-connections`, `--worker-max-rss` (MB, Linux) or `--worker-max-age` (seconds). A replacement starts first and takes all new connections; the old worker finishes its live connections, then exits. `--worker-drain-timeout` (default 120 s) bounds that wait, after which remaining connections are closed, so set it above your longest session.++```bash+obscura serve --workers 50 --worker-max-connections 500 --worker-max-rss 1500+```+## V8 heapThe V8 old-generation ceiling is 4 GB on 64-bit systems. The defaults request `--max-semi-space-size=4`, but the current V8's `--optimize-for-size` implication overrides the effective semi-space cap to 1 MiB. Override the old-generation ceiling with: