Designing a High-Density Execution Platform for Reinforcement Learning Sandboxes
This article explains how to design a high-density execution platform for reinforcement learning (RL) sandboxes used in agentic model training and evaluation. It outlines seven workload characteristics that break traditional cloud-native assumptions, then details four core infrastructure areas: environment provisioning through content-addressed chunked storage and lazy materialization, decentralized scheduling with local-first placement and two-phase commit, composable isolation and quota policies for untrusted execution, and layered state persistence and recovery. The discussion is grounded in the constraint of more than 5,000 sandbox creations per second.
Introduction: Why RL Sandboxes Break Traditional Cloud Assumptions
As large models move into the agentic training stage, the infrastructure bottleneck shifts from “is there enough compute” to “can environments be created at the right time, in the right place, with the right isolation strength.” An internal execution platform carries the full reinforcement learning training and evaluation sandbox workloads for the V3.2 through V4.1 model series. Its scale and volatility are representative: a single scale unit consists of roughly 160 CPU nodes, 30,000 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 RL job can request up to 32,000 sandboxes at once, and those requests arrive within a very short window.
These numbers point to one core fact: a creation rate above 5,000 per second is the key to understanding the entire platform design. At that scale, any centralized routing table or any scheduling decision that requires cross-instance coordination becomes a throughput bottleneck. Every architectural choice that follows is essentially forced by this set of numbers.
1. Seven Characteristics of Agentic Training Workloads
The platform team identified seven characteristics of agentic workloads, each of which overturns a traditional cloud-native assumption.
Pulsed creation. Training and evaluation batches cannot use instances until the environment is ready, so requests are not a steady trickle but a pulse flood. Capacity planning based on average utilization severely underestimates peak pressure.
CPU-sparse but high-density. Agents spend most of their time waiting for the model to generate the next action. In practice, about 90% of sandboxes consume less than 5% of their requested CPU on average. This makes oversubscription not an optimization but a requirement, and oversubscription must be built on reliable isolation and rate limiting.
Stateful and long-lived. The model modifies files, installs dependencies, and starts services, and later tool calls depend on this accumulated state. The median lifetime is about 15 to 17 minutes, with a p99 exceeding 3 hours. Even when the CPU is idle, the memory footprint, page cache, and writable state remain pinned, so the “release when idle” assumption does not hold.
Highly heterogeneous. Workloads coexist across online judge script execution, full-repository software engineering tasks, security offense and defense, graphical interface operation, mobile development, and complete system environments. Isolation strength and resource profiles vary widely, and a single sandbox abstraction cannot cover all needs.
Explosive environment diversity. One week of production data shows 11,266 base images, 102,171 workspaces, and 103 toolkits, totaling more than 130 TB. Image reuse is extremely low; the p50 fanout for microVMs is only 1, so local image caching is nearly ineffective. Meanwhile, the image data actually accessed at runtime is only 4.2% to 13.3%. For example, a 6 GB general-purpose language image is only about 6% read.
Untrusted execution. Agents may damage the file system, exhaust resources, or interfere with system components, so isolation, quotas, and auditing must be designed with untrusted execution as the default.
Interruptible execution. GPU training jobs may be preempted, but the reasoning inside them continues, so the platform must be able to save and efficiently restore execution state.
These seven points converge into four infrastructure challenges: environment provisioning efficiency, scheduling and placement, isolation and resource governance, and state persistence and recovery. This article is organized around these four threads.
2. Environment Provisioning: Decoupling Setup Cost from Decompression Count
Traditional container platforms rely on “pull image plus local cache,” which degrades into repeated decompression under low-reuse conditions. The solution is to treat images as chunked, content-addressed datasets and to do three things on the data path.
First, globally deduplicated chunked storage. Image layers are split into fixed-size chunks, addressed by content hash, and stored in object storage or distributed block storage. Metadata describes the file system view and the chunk manifest.
Second, on-demand lazy materialization. Instance startup loads only metadata and a small number of bootstrap chunks; the remaining chunks are fetched on first access. This compresses the startup cost of a 6 GB image to roughly the 6% actually accessed.
Third, node-level chunk caching and prefetching. Even with a fanout of 1, window prefetching can still be driven by job declarations, historical access sequences, and batch topology, turning burst traffic into sequential reads.
Illustrative pseudocode:
create_sandbox(image_ref, workspace_ref):manifest = metadata_store.get(image_ref) # metadata only, millisecond-levelblocks = local_block_cache.plan(manifest) # skip on cache hitvm = microvm.launch(rootfs=lazy_mount(manifest, blocks))prefetch(manifest, hints=job.access_history) # window prefetchreturn vm
3. Scheduling: Local-First, No Central Routing, Two-Phase Commit
Under a constraint of thousands of creations per second, scheduling must avoid a global consistency view. A workable pattern is “local-first plus lazy binding”: the control plane only dispatches jobs and quotas, nodes select instances themselves, and creation requests first land on nodes that have the chunk cache and free memory, then report asynchronously. For a higher success rate, a two-phase commit can be used: the first phase reserves memory and a chunk cache window, the second phase commits the launch, and timeouts roll back automatically.
The placement objective function should consider memory fragmentation (long-lived stateful instances cannot be reclaimed arbitrarily), chunk cache hits, network topology, and isolation level requirements. Lightweight virtualization is used for high-isolation scenarios, containers with a hardened kernel and mandatory access control for low-trust scripts, and dedicated images with device emulation layers for graphical and mobile scenarios.
4. Isolation and Governance: A Quota System Under Default Distrust
Untrusted execution requires resource governance to be built as composable policies: copy-on-write file systems with quotas, process and handle limits, network egress allowlists, system call filtering, audit logs, and behavior sampling. For high-density oversubscription, it is necessary to distinguish “requested amount” from “actual usage,” and to use low-priority reclamation, memory compression, and page cache reclamation policies to ensure long-lived instances are not harmed by mistake.
5. State Persistence and Recovery
For interruptible execution, state saving should be layered: memory snapshots for second-level recovery, file system increments for cross-node migration, and tool call context for semantic-level replay. The recovery path should reuse the same chunk cache system as image lazy loading, avoiding another decompression storm during recovery.
Conclusion
A sandbox platform for reinforcement learning is essentially a distributed systems problem of “high density, low reuse, strong state, and default distrust.” Understanding the constraint of thousands of creations per second explains why scheduling must be decentralized, why content addressing and lazy loading are needed, and why isolation and quotas must be built as policy combinations. Baidu AI Cloud’s practices in container platforms, object storage, and monitoring and alerting also provide a reference engineering paradigm for building such platforms.
