High-Density Architecture Design for Reinforcement Learning Sandbox Platforms

    This article examines the architecture of a high-density sandbox platform built for large-scale reinforcement learning. It breaks down seven production workload characteristics of AI agent tasks, the four infrastructure challenges they create, and the design choices that follow: decentralized control plane, on-demand layered environment supply, tiered isolation with oversubscription guardrails, and snapshot-based state recovery. Infrastructure and platform engineers will find concrete scale figures, design rationale, and tradeoffs for building high-concurrency execution environments.

    1. Background: Reinforcement Learning Turns the Sandbox into Infrastructure

    Once large models move into the reinforcement learning stage, a component that was long underestimated appears in the training loop: the sandbox execution platform. It must provide an executable code environment, an interactive terminal, and a persistent filesystem for every rollout, while maintaining isolation and recoverability across thousands of concurrent tasks. Data from an internal platform illustrates the scale: a single scale unit consists of roughly 160 CPU nodes, 30,000 physical cores, and 250 TB of memory. It creates about 3 million sandbox instances per day, with a peak concurrency of around 380,000 and a creation rate exceeding 5,000 per second. A single node can stably run 800 microVMs or 3,200 containers. A single training job requests 32,000 sandboxes at once, and they arrive within a very short window.

    The key takeaway from these numbers is this: a creation rate of 5,000 per second is the key to understanding the entire architecture. At this scale, any centralized routing table, any scheduling decision that requires cross-instance negotiation, and any synchronous image pull degrades from “a bit slow” to “unusable.” Every design choice that follows is derived backward from these numbers.

    2. Seven Workload Characteristics of AI Agents: Each One Breaks a Traditional Assumption

    The platform team summarized production workloads into seven characteristics that together invalidate several default assumptions of traditional virtualization platforms.

    1. Bursty creation. Training and evaluation batches cannot progress until the environment is ready. Requests do not arrive as a steady trickle but as a flood. The creation path must therefore be stateless and horizontally scalable, and pre-warmed resources must be rolled out in advance.
    2. Sparse CPU but mandatory high density. Agents spend most of their time waiting for the model to generate the next action. Measurements show that about 90% of sandboxes average less than 5% of their requested CPU usage. Oversubscription is therefore not an optimization but a requirement, and the scheduler must pack primarily by memory and state rather than by CPU.
    3. Stateful and long-lived. The model modifies files, installs dependencies, and starts background services, and later tool calls depend on this accumulated state. The median lifetime is 15 to 17 minutes, and p99 exceeds 3 hours. Even when the CPU is idle, the memory footprint, page cache, and writable layer remain pinned, which directly determines the density ceiling.
    4. Highly heterogeneous. Workloads range from judge-style script execution and full-repository code modification to security offense and defense, GUI operation, mobile development, and full-system environments. Isolation strength and resource profiles vary enormously, so a single abstraction cannot cover them all and a tiered sandbox spectrum is required.
    5. Exploding environment diversity. One week of production data contains 11,266 base images, 102,171 workspaces, and 103 tool sets, totaling more than 130 TB. Image reuse is extremely low: the median reuse for microVMs is just 1, so local caching is nearly ineffective. More importantly, the data actually read at runtime accounts for only 4.2% to 13.3% of an image—a 6 GB image is only about 6% touched in practice.
    6. Untrusted execution. Agents may delete files by mistake, exhaust resources, interfere with system components, or even actively probe isolation boundaries. Isolation must therefore be on by default and impossible to bypass.
    7. Interruptible execution. Compute training jobs can be preempted while rollouts are still in progress, so the platform must be able to save and efficiently resume the execution state.

    3. Converging the Challenges and the Architecture Main Line

    These characteristics converge into four infrastructure challenges that form the main line of this article: environment supply efficiency (bursty creation combined with environment diversity), density and oversubscription safety (sparse CPU combined with long-lived state), isolation and trusted execution, and state snapshotting and fast recovery.

    The corresponding architecture choice follows naturally: a fully decentralized control plane. Instance creation does not consult a global table; instead, the hosting node makes its own decision based on a local resource view, and the scheduling center only pushes down capacity watermarks and policies. Creation requests connect directly to nodes by consistent hashing or job sharding, preventing the center from becoming a hotspot.

    1. Creation path (no central coordination):
    2. job -> shard by sandbox_id -> node-local admission
    3. -> local image layer ready? --no--> on-demand pull (lazy loading)
    4. -> microVM/container start -> return handle

    4. Environment Supply: Removing “Decompression Cost” from the Critical Path

    Low reuse rates make the traditional “pull the image into a local cache” model completely ineffective. The viable approach is layered on-demand supply: split images into content-addressed chunks, deliver metadata first, and lazy-load the data plane, fetching the corresponding chunk on a runtime page fault. Combined with peer-to-peer distribution between nodes and global deduplication, this turns 130 TB of cold data into amortizable read bandwidth. Since the actual touch rate is below 15%, lazy loading reduces first-start time from transferring the whole image to fetching metadata plus a few chunks.

    5. Isolation and Density: Tiered Sandboxes and Oversubscription Guardrails

    Three isolation tiers are recommended: lightweight containers for low-sensitivity judge-style workloads; microVMs for untrusted code execution; and full-machine environments for system and mobile scenarios. For density, memory and writable state are the primary constraints. Set an upper bound on the oversubscription factor, throttle by per-job quota, and apply resource circuit-breaking to abnormal processes, so that a single rollout cannot bring down an entire node.

    6. State Saving and Recovery

    Long lifetimes and preemptibility require externalizing the execution state: a copy-on-write filesystem plus incremental snapshots, with memory pages dumped on demand. On recovery, rebuild metadata and hot pages first while cold pages continue to lazy-load. This allows a preempted workload to resume quickly on another node without replaying the entire environment build process.

    7. Conclusion

    The engineering essence of a large-scale reinforcement learning sandbox platform is making deterministic tradeoffs among burst floods, sparse compute, long-lived state, and diverse environments: decentralized creation, lazy-loaded supply, tiered isolation, and snapshot recovery. Baidu AI Cloud provides a composable infrastructure foundation for similar high-concurrency execution platforms through general capabilities such as container platforms, object storage, and monitoring and alerting.