ModalProblem & solution
Scaling to 1 million concurrent sandboxes in seconds
Summary
Modal rebuilt its sandbox platform to support millions of concurrent sandboxes and tens of thousands of creations per second, removing all central bottlenecks from the control plane. The new architecture eliminates central coordination and durable datastores from the critical path, using horizontally scaled scheduling servers that run a fast load-balancing algorithm against in-memory cached worker state from Redis streams. Workers are contacted directly via RPC to create sandboxes, and sandbox metadata is written asynchronously, avoiding O(sandboxes) and O(nodes) operations that limited previous systems. In a benchmark, Modal created 1 million sandboxes in under a minute with median time-to-interactivity under half a second, though the long tail is attributed to kernel and network contention like the rtnl lock. The system is designed to scale without practical limits, supporting use cases like reinforcement learning and background agents that require massive concurrent sandbox creation.
Context
Modal’s engineering team describes the redesign of their sandbox platform to handle millions of concurrent sandboxes, motivated by customer needs for reinforcement learning and agent workloads that require high creation rates and massive concurrency.
Approach / What changed
Rebuilt the sandbox platform from scratch with no central coordination: horizontally scaled scheduling servers run a fast load-balancing algorithm against in-memory cached worker state from Redis streams; workers are contacted directly via RPC to create sandboxes; sandbox metadata is written asynchronously; all O(sandboxes) and O(nodes) operations are horizontally scalable.
Takeaways
The new architecture removes all central bottlenecks by eliminating durable datastores from the critical path of sandbox creation, using only in-memory state and asynchronous writes.
Scheduling is performed by a fleet of servers running a fast load-balancing algorithm against cached worker state, allowing horizontal scaling without coordination.
In a benchmark, Modal created 1 million sandboxes in under a minute with median time-to-interactivity under half a second, though the long tail is affected by kernel contention.
FAQ
How does the new architecture avoid central coordination?
It uses horizontally scaled scheduling servers that consume worker state from Redis streams asynchronously and contact workers directly via RPC, with no durable datastore in the critical path of sandbox creation.
What were the main bottlenecks in the old system?
The old system relied on strong consistency and Postgres in the critical path, causing O(sandboxes) and O(nodes) operations that didn't scale, such as durable workflows per sandbox and unsharded Postgres writes.
What is the performance of the new system?
In a benchmark, 1 million sandboxes were created in under a minute, with median time-to-interactivity under half a second. The long tail is attributed to kernel and network contention, such as the rtnl lock.
Source and freshness
- Source
- modal.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.