Designing a High-Density Execution Platform for RL Sandboxes
This article examines the design of a production-grade execution platform built for reinforcement learning (RL) sandboxes, where the workload is defined by burst creation rates exceeding 5,000 sandboxes per second, sparse but high-density CPU usage, long-lived stateful instances, and massive environment diversity. It breaks down seven characteristics of agentic workloads and the four infrastructure challenges they create, then maps each challenge to an engineering approach: on-demand page fetching instead of full image distribution, oversubscription as a constrained scheduling problem, two-tier isolation runtimes, and snapshots as the recovery unit for preemptible stateful instances. It closes with field failure patterns and the layered defenses they motivate, offering a practical reference for building elastic execution infrastructure.
1. Why Traditional Container Platforms Cannot Handle RL Sandbox Workloads
A leading AI team published a paper on a reinforcement learning sandbox execution platform, and one framing statement is worth remembering up front: this is not a sandbox runtime, nor a thin wrapper around containers, but a production-grade execution platform. The distinction matters—the subject is not “how to run an isolated environment,” but “how to reliably deliver millions of isolated environments every day.”
Start with the scale. A single scale unit is roughly 160 CPU nodes, 30,000 cores, and 250 TB of memory. It creates 3 million sandbox instances per day, with a peak concurrency of about 380,000 and a creation rate exceeding 5,000 per second. A single node stably hosts 800 microVMs or 3,200 containers. A single RL job requests 32K sandboxes at once, all arriving within an extremely short window.
Among these numbers, the 5,000/s creation rate is the key to understanding the entire platform. At this magnitude, any centralized routing table or any scheduling decision that requires cross-instance coordination immediately becomes a bottleneck. Every subsequent design choice was forced by these numbers, not by the designers’ prior aesthetic preferences.
2. Seven Characteristics of Agentic Workloads That Overturn Traditional Assumptions
1. Burst creation. Training and evaluation batches cannot use instances until the environment is ready. The request pattern is not a trickle but a pulse flood. This directly invalidates capacity planning based on average load; capacity must be constrained jointly by peak arrival rate and queueing latency.
2. CPU-sparse but must be high-density. Agents spend most of their time waiting for the model to generate the next action. Measurements show that about 90% of sandboxes use less than 5% of their requested CPU on average. Oversubscription is not an optimization but an inevitability; the hard part is isolating occasional dense compute spikes after oversubscribing.
3. Stateful and long-lived. Models modify files, install dependencies, and start background services, and subsequent tool calls depend on this accumulated state. The median lifetime is 15–17 minutes, and p99 exceeds 3 hours. CPU may be idle, but memory footprint, page cache, and writable state remain pinned—the real bottleneck for this kind of workload is memory and state, not compute.
4. Highly heterogeneous. Online judge-style script execution, repository-wide code modification, security offense and defense, GUI operation, mobile development, and full-system environments differ enormously in isolation strength and resource profiles. A single sandbox abstraction inevitably faces a dilemma: either too strong and wasteful, or too weak and unsafe.
5. Explosive environment diversity. One week of production data shows 11,266 base images, 102,171 workspaces, and 103 tool sets, totaling more than 130 TB. Each image has extremely low reuse; the median reuse fan-out for microVMs is 1, and local image caching is essentially ineffective. Yet the runtime actually accesses only 4.2%–13.3% of an image’s data—a 6 GB general-purpose language image is only about 6% read in practice.
6. Untrusted execution. Agents may corrupt the filesystem, exhaust resources, or interfere with system components. “Failure is the norm” must be written into the design premises.
7. Execution can be interrupted. Upper-layer compute tasks may be preempted at any time, but a rollout is still in progress. The platform must be able to save and efficiently restore execution state.
3. Four Infrastructure Challenges
The seven characteristics above converge into four main threads—questions any comparable platform must answer:
- Environment supply efficiency: how to reduce the latency of “fetching an environment” to milliseconds, given a fan-out of 1 and data volumes in the hundreds of TB;
- Balancing density and isolation: how to oversubscribe under a reality of 5% average utilization without letting a few dense workloads drag down their neighbors;
- State lifecycle management: how to save, migrate, and restore long-lived stateful instances at low cost;
- Control-plane scalability: how to avoid any centralized coordination at a creation rate of 5,000/s.
4. Design in Practice: Four Engineering Threads
4.1 Environment Supply: From “Full Image Distribution” to “On-Demand Page Fetching”
Since the actual access rate is only single digits to low double digits, moving entire images is pure waste. The viable path is layering and lazy loading: split images into content-addressed blocks, fetch them on page-fault requests, and combine node-level shared caching with deduplication so that many “fan-out of 1” instances on the same node can still share common read-only layers. The logic is roughly:
start(image descriptor) ->mount read-only layers(content-addressed blocks, fetched on demand) ->first access triggers fetch(block) ->node cache hit ? map directly : fetch from remote object storage and backfill
Three engineering points need attention: prefetching should be based on historical access sequences rather than full scans; cache eviction should distinguish “common read-only layers” from “instance-private writable layers”; and the image repository side should rely on general-purpose capabilities like object storage, avoiding node-local disk becoming the capacity ceiling.
4.2 Density: Making Oversubscription a Constrained Scheduling Problem
The premise of oversubscription is reclaimability. A viable approach is to use “requested amount” rather than “used amount” as the book quota, corrected by periodic sampling of actual usage, and to set separate resource pools or quota caps for compute-intensive workloads to prevent a single agent’s compile or test storm from encroaching on neighbors. Scheduling decisions should be pushed down to the node as much as possible; the control plane only handles sharding and admission, not per-instance global optimization.
4.3 Tiered Isolation: Covering Heterogeneous Needs with Two Runtime Tiers
For the vast majority of workloads that only need filesystem and network isolation, lightweight containers suffice; for untrusted code, kernel-level operations, and full-system environments, switch to microVMs and hardware virtualization boundaries. The key is to make “isolation strength” a dimension of the instance spec, explicitly declared by the job, rather than a one-size-fits-all decision by the platform.
4.4 State and Preemption: Snapshots as the Recovery Unit
For long-lived stateful instances, memory and the writable layer should be captured together in a snapshot. On restore, rebuild the page tables and backfill the cache so that p99 long-tail instances can resume in seconds after preemption. Snapshots are stored in shared storage, allowing reconstruction on other nodes when a node fails—this is also how the assumption that “nodes are volatile resources” is institutionalized.
5. Lessons from Production Incidents
The field failures recorded in the paper are representative: agents filling the disk, fork bombs, tampering with environment variables that break the entire downstream chain, and starting long-running services inside the sandbox that occupy ports. The corresponding defenses are layered quotas (process count, file descriptors, write bandwidth), injecting an immutable baseline at startup, mounting system component directories read-only, and treating “the environment is already polluted” as a first-class reportable state so the scheduler discards it outright rather than attempting repair.
6. Conclusion
The methodology of this class of platform can be condensed into one sentence: first measure the true shape of the workload, then make the architecture obey the numbers. Burst arrival dictates a decentralized control plane, sparse utilization dictates oversubscription, long-tail images dictate on-demand page fetching, and untrusted plus preemptible execution dictates tiered isolation and state snapshots. Baidu AI Cloud’s combination of general-purpose capabilities in container platforms, object storage, and monitoring and alerting provides a reference for selecting foundational components to build a comparable elastic execution substrate.
