High-Density Sandbox Platform Design for Agent RL Training

    A high-density sandbox platform for agent reinforcement learning must absorb thousands of instance creations per second, extreme CPU underuse, near-zero image reuse, and long-lived state. This article explains why centralized scheduling fails at that scale and how environment supply, oversubscription, tiered isolation, and preemption recovery fit together.

    1. Start with scale: why centralized scheduling fails

    Before discussing a sandbox platform, the load magnitude has to be clear. Public data from a leading model team’s RL execution platform shows that one scale unit contains about 160 CPU nodes, 30,000 physical cores, and roughly 250 TB of memory. It creates about 3 million sandbox instances per day, peaks at roughly 380,000 concurrent instances, and exceeds 5,000 creations per second. A single node can steadily run about 800 lightweight virtual machines or 3,200 containers. One RL job may request up to 32,000 sandboxes in a single run, and those requests arrive in a very short window.

    The decisive number is the creation rate of more than 5,000 per second. Any control plane that maintains a global routing table on a central node, or makes scheduling decisions that require cross-instance coordination, will be overwhelmed immediately. Every later architectural choice is driven by that rate: the control plane must be stateless and horizontally shardable, the data plane must be decentralized, and environment distribution must not let central bandwidth become a single point of failure.

    2. Seven workload traits that overturn conventional assumptions

    1. Bursty creation. Training and evaluation batches cannot proceed until environments are ready. Requests arrive as pulses, not a steady trickle. The traditional CI model of queueing for a scheduler fails here. Capacity must be planned for the peak, not the average.

    2. Sparse CPU use, 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 use less than 5% of the CPU they requested on average. Exclusive allocation by requested CPU is therefore extremely wasteful. Oversubscription is not an optimization; it is required. It is viable only if workloads are preemptible and can be restored quickly, or noisy neighbors will stall long-tail tasks.

    3. Stateful and long-lived. The model edits files, installs dependencies, and starts background services. Later tool calls depend on that accumulated state. Measured lifetimes have a median of 15 to 17 minutes, with p99 above three hours. CPU may be idle while memory footprint, page cache, and writable-layer state remain pinned. The real bottlenecks are memory and storage I/O, not CPU.

    4. Highly heterogeneous. Workloads range from problem-judging scripts and repository-scale software engineering to security offense and defense, GUI operations, mobile development, and full-machine system environments. Isolation strength and resource profiles differ sharply. A single sandbox abstraction cannot cover them. The platform needs capability tiers plus composable abstractions.

    5. Exploding environment diversity. One week of production data from one platform included 11,266 base images, 102,171 workspaces, and 103 toolsets, totaling more than 130 TB. Reuse per image is extremely low. The median image fan-out for lightweight VMs is only 1, so local image caches are almost useless. At runtime, the data actually read is only 4.2% to 13.3% of the image. A 6 GB runtime image may have only about 6% of its bytes read. Full prewarming and whole-package distribution are uneconomical. The platform must load on demand and deduplicate at the content level.

    6. Untrusted execution. An agent may damage the filesystem, exhaust resources, interfere with host components, or probe isolation boundaries. The platform must treat all code inside the guest as hostile by default.

    7. Interruptible execution. The GPU training side can be preempted at any time while rollouts are still running. The platform must save and efficiently restore execution state, and restore latency must be substantially lower than the cost of rerunning.

    3. Environment supply: decouple setup cost from repetition

    For traits 1 and 5, the goal is to make environment preparation cost independent of how often an environment is reused.

    • Content addressing and global deduplication. Split images into chunks by content hash and share common layers across images, so 130 TB of logical data can shrink substantially on the physical side.
    • Lazy pulling. Fetch a chunk only when it is accessed, turning a roughly 6% actual read rate into direct savings in bandwidth and time.
    • Decentralized distribution. Treat nodes as cache units and use peer-to-peer or tree-style propagation instead of pulling every image from a central repository, so central bandwidth does not collapse at 5,000 creations per second.
    • Prefetch and heat tiering. Prefetch within a window based on historical access sequences. Keep cold data in low-cost object storage and sink hot data to local node storage.

    An illustrative policy:

    1. environment_supply:
    2. chunk_size: 1MiB
    3. dedup_scope: cluster # cluster-wide content deduplication
    4. pull_mode: on_demand
    5. prefetch:
    6. window: 30s
    7. trigger: access_sequence # prefetch from historical access sequences
    8. distribution:
    9. mode: peer-assisted # decentralized distribution, no central pull hotspot
    10. local_cache_quota: 200GiB
    11. tiers:
    12. hot: node_local_ssd
    13. warm: cluster_cache
    14. cold: object_storage

    4. High density and oversubscription: size for memory, not CPU

    Because 90% of instances use less than 5% of requested CPU, the scheduler should rank primarily by memory footprint, page-cache pressure, and I/O quota, with CPU only as a secondary constraint. Three supporting mechanisms are required: graded memory reclamation, reclaiming reconstructable guest page cache first and writable state last; write-amplification control on the writable layer through copy-on-write plus periodic compaction; and noisy-neighbor isolation through I/O and network bandwidth quotas plus a minimum CPU weight.

    A density of 800 lightweight VMs or 3,200 containers per node is sustainable only after fast freeze/restore and memory sharing—deduplicating read-only pages from the same image—are both in place.

    5. Tiered isolation: composition instead of one abstraction

    Define three isolation tiers and route tasks by risk profile:

    Tier Form Typical use
    L1 Strongly isolated process or container Judging, script execution, light single-repo tasks
    L2 Lightweight virtual machine Repository-scale software engineering, dependency installation, multi-process services
    L3 Full machine or nested virtualization Security offense and defense, kernel experiments, GUI and mobile environments

    The common base is four controls: resource quotas, filesystem isolation, system-call filtering, and egress policy. Tiers differ only in the virtualization layer and the scope of device passthrough.

    6. Untrusted execution and preemption recovery

    Defenses against untrusted execution are layered: a read-only root plus a separate writable layer, a system-call allowlist, a reduced capability set, default-deny egress opened only when needed, and no exposure of host components or device nodes. Abnormal behavior such as fork bombs, filling the disk, or port-scan patterns should trip circuit breakers and automatic reclamation.

    Preemption recovery requires snapshotable state. Prefer snapshots of the writable layer and process-tree metadata, and save memory pages selectively by heat. Restore should prefer local-node reuse within the same job, bringing restore latency down to roughly one-tenth of the rerun cost.

    7. Engineering checklist

    1. Make the control plane fully stateless, shard by job hash, and forbid a global routing table.
    2. Make creation asynchronous: return a handle first and callback when the environment is ready, so synchronous waits do not block the control plane.
    3. Treat p99 creation latency and p99 restore latency as primary SLOs, not average creation latency.
    4. Build dashboards for image heat and fan-out, and continuously retire zero-fan-out images.
    5. Push observability down to the node: memory pressure, page-cache hit rate, chunk-cache hits, and write-amplification ratio.
    6. On public cloud, this kind of platform usually sits on general product categories such as a container platform, object storage, an image registry, logging, and monitoring and alerting. General categories from vendors such as Baidu AI Cloud can serve as that base, but decentralized distribution and on-demand loading still have to be built by the platform itself.

    8. Summary

    The hard part of a high-density RL sandbox platform is not whether a container can be started. It is making environment supply, resource oversubscription, tiered isolation, and state recovery into one coherent system when four constraints hold at once: thousands of creations per second, about 90% of instances idle on CPU, image fan-out of 1, and task lifetimes with a tail of several hours. A design is adequate if three metrics hold: p99 latency at peak creation rate, memory-backed density per node, and the cost of recovery after preemption.