TESTBED REPRODUCIBILITY NOTICE: Concurrency and cold-start metrics were physically measured in isolated testbed containers. Memory footprint (RSS) was evaluated using Linux procfs telemetry across 40 concurrently active workers.
High-Density Process Sandboxing: Running 100+ Isolated Task Workers on a 1GB VPS
Abstract
“Hosting dozens of independent micro-tasks, Discord bot instances, or webhook consumers typically relies on multi-process forks or container-per-tenant architectures (Docker/Kubernetes). Under strict resource environments (such as a 1 vCPU / 1 GB RAM VPS), multi-process approaches collapse prematurely due to redundant V8 runtime and binary overhead (35–45 MB per instance), triggering Out-Of-Memory (OOM) failures after merely 24 concurrent workers. In this paper, we propose and test a memory-clamped Worker Thread sandboxing architecture. By strictly bounding V8 heap generations (16MB old generation, 4MB young generation) and sharing the parent runtime, per-worker memory consumption collapses to 8.85 MB. On a 2 vCPU / 2 GB testbed, 40 workers achieve complete cold-start initialization in 5.85 seconds (146.4 ms per worker)—a 2.58x acceleration compared to single-core environments.”
The Cost of Container & Process Redundancy
Every full Node.js process fork duplicates the entire V8 compilation pipeline, core libraries, and garbage collection metadata in RAM, wasting 80% of host memory on identical runtime boilerplate.
- A.1Shared Runtime, Isolated State: Multiple worker actors should share read-only executable code pages while strictly isolating user state.
- A.2Heap Bounds Prevent OOM Cascades: Unrestricted V8 heaps expand dynamically until the Linux kernel OOM-killer terminates the entire host service.
- A.3Cold-Start Latency Scales Linearly with Memory Allocation: The less RAM allocated per instance, the faster the thread enters its execution loop.
Worker Density Theoretical Bound
The theoretical maximum concurrency capacity N_max is constrained by available RAM and per-instance memory allocation.
N_{max} = \left\lfloor \frac{M_{available} - M_{parent\,overhead}}{M_{worker\,RSS}} \right\rfloorWhere reducing per-worker RSS from 38.5 MB to 8.85 MB shifts N_max from 24 to over 102 concurrent tasks on a standard 1024 MB VPS.
Comparative Performance Metrics
Empirical measurement of 40 concurrent active workers evaluated inside 1 vCPU / 1 GB RAM vs 2 vCPU / 2 GB RAM isolated testbeds.
| Isolation Architecture | Testbed Tier | Active Workers | Total Spawn Duration | Avg Cold-Start / Worker | Total Measured RSS | Avg RAM / Worker | Max Capacity (1GB Limit) |
|---|---|---|---|---|---|---|---|
| Multi-Process Fork (child_process.fork) | 1 vCPU / 1 GB | 30 workers | 3,273.1 ms | 109.1 ms | 1,202.6 MB (OOM Risk) | 38.5 MB | 24 workers |
| Leviora Clamped Workers (16MB Heap Limit) | 1 vCPU / 1 GB | 40 workers | 15,142.5 ms | 378.5 ms | 440.2 MB | 8.85 MB | 102 workers (+325%) |
| Leviora Clamped Workers (16MB Heap Limit) | 2 vCPU / 2 GB | 40 workers | 5,859.7 ms (-61%) | 146.4 ms (2.6x faster) | 447.6 MB | 9.07 MB | 210 workers (+775%) |
On 2 vCPU / 2 GB, worker cold-start speed improved by 258% due to dual-core parallel isolate compilation without increasing memory overhead.
Memory-Clamped Sandboxing Architecture
V8 Isolate Heap Clamping
Workers are initialized with resourceLimits restricting maxOldGenerationSizeMb to 16MB, preventing runaway heap inflation.
Shared Binary Runtime
All workers reference the master Node.js executable and core standard libraries in read-only memory pages.
Zero-Overhead Event Heartbeat
Idle workers yield CPU cycles completely, waking only when incoming messages arrive on MessagePort channels.
V8 Isolate Clamping & 40-Worker Density Harness
Verifies memory footprint and cold-start compilation times across 40 concurrently active Worker Threads under containerized memory constraints.
docker run --rm -it --network=none --cpus=2.0 --memory=2g node:22-trixie-slim- 1Spawns an isolated container constrained to 2 vCPU cores and 2 GB RAM envelope.
- 2Instantiates 40 concurrent Worker Threads configured with resourceLimits: { maxOldGenerationSizeMb: 16 }.
- 3Dispatches concurrent synthetic computing cycles to all 40 workers via MessagePort channels.
- 4Continuously samples process.memoryUsage().rss to compute true per-worker memory footprint.
Conclusions & Open Inquiries
- →Running separate Docker containers for lightweight bot tasks on a small VPS is an unnecessary operational overhead.
- →Clamping V8 worker heaps to 16MB enables 4x higher service density on the same physical hardware.
Other Active Working Theses
Pushing Embedded SQLite to the Physical Edge: Zero-Network Storage under Strict Memory Caps
By eliminating TCP network round-trips and combining SQLite WAL2 with 512MB memory-mapped I/O and exclusive locking, embedded storage achieves over 207,000 writes/sec and 261,000 reads/sec with a 3.2-microsecond median latency on a 2-core virtual instance.
Resilient Traffic Shedding: Token-Bucket Gatekeeping Under Single-Core CPU Saturation
Deploying a lightweight token-bucket traffic shedder at the application threshold reduces p99 request latency by 48.8% (from 40.9ms to 20.9ms) and increases overall query throughput by 47% under sustained synthetic burst flooding.
