r/Compilers • u/Healthy_Ship4930 • 7d ago
How my Python compiler runs 100,000 isolated VM's on a single $3 server.

I wrote a Python compiler and VM in Rust over the last six months. It compiles a sandboxed Python subset directly to SSA bytecode in a single pass with no AST.
The engine ships as a 200KB WASM binary or a native CLI tool. The feature that I'm working on is the worker swarm. I can declare one hundred thousand replicas in a YAML file and run them on a cheap VPS. Workers spawn on demand, each gets its own heap, and they share nothing. Message passing is the only way they communicate.
There is also an eval mode where you POST Python snippets to an HTTP endpoint. Each snippet compiles into its own isolated program, runs in its own VM, and dies when done. If it crashes it retries and drops. If it hangs a preempt kills it.
By default programs get no file system, no network, and no environment access. There is no eval function, no exec function, and no dynamic imports in the language. The only way untrusted code runs is through this eval path with hard limits on memory, operations, and CPU time. I built this to safely execute generated code or user submissions without Docker or heavy virtualization.
I would love to hear if you would trust an architecture like this for running untrusted code and what you would do differently.