Cost Models // FlowLedger Research
Node.js & V8 Isolate Heap Ceilings Against Container OOM Kills
Uncapped Node.js worker heaps collide with Docker mem_limit during JSON parsing bursts; align AP_SANDBOX_MEMORY_LIMIT with --max-old-space-size.
Measured Unit Economics & Telemetry
Linux cgroups kill the entire Activepieces container with exit code 137 the instant RSS exceeds mem_limit—dropping all concurrent flows mid-flight. Capping per-sandbox memory via AP_SANDBOX_MEMORY_LIMIT (128 MB = 131072 KB) and bounding Node main heap to 70% of container mem_limit forces V8 garbage collection before the kernel OOM killer fires.
| Resource / Billing Line | Audited Value | FinOps Impact |
|---|---|---|
| AP_SANDBOX_MEMORY_LIMIT (Code) | 131072 KB (128 MB) | Blocks runaway array/regex loops per step |
| AP_SANDBOX_MEMORY_LIMIT (Full) | 262144 KB (256 MB) | Safe margin for heavier npm transforms |
| NODE_OPTIONS Old Space Ratio | 70% of mem_limit | Leaves 30% for V8 native buffers & isolates |
| Container Exit 137 Prevention | 0 OOM restarts | Graceful step-level error instead of node crash |
Implementation & Configuration Checklist
- Compute 70% Old-Space Ceiling: For a 4,096 MB Activepieces container mem_limit, set NODE_OPTIONS=--max-old-space-size=2867.
- Set Explicit AP_SANDBOX_MEMORY_LIMIT: Enforce 131072 KB in SANDBOX_CODE_ONLY so a single bad CSV parse fails cleanly without crashing peer flows.
- Stream Large Files Instead of JSON.parse: Keep binary/CSV transforms under 10 MB per step or offload multi-hundred-MB ETL outside webhook workers.
AP_SANDBOX_MEMORY_LIMIT=131072
NODE_OPTIONS=--max-old-space-size=2867
mem_limit: 4096m
Workflow Infrastructure FAQ
Why does Node RSS exceed --max-old-space-size?
V8 allocates native C++ buffers, Buffers, and isolated-vm contexts outside the JS old-space heap, requiring 25-30% container headroom.
What unit does AP_SANDBOX_MEMORY_LIMIT expect?
Kilobytes (KB): 131072 equals 128 MB and 262144 equals 256 MB.