r/lowlevel • u/AuthorJazzlike3254 • 23d ago
I'm building a lightweight code execution sandbox from scratch — would love some architecture feedback
I've been working on a project called SuperSand for a while now.
The basic idea is pretty simple: I want to run untrusted user code securely, but with as little overhead as possible. Think something in the direction of serverless/code execution platforms, but I'm building most of the sandboxing layer myself using Linux primitives instead of putting Docker/Kubernetes underneath everything.
Right now I have a Go service that handles requests, IPC and sandbox management. The sandbox itself uses Linux namespaces, resource limits, isolated filesystems, etc.
Recently I've been experimenting with pre-warmed workers.
Instead of creating a completely new sandbox for every request, I can keep a bunch of isolated workers alive, mount the user's workspace when a request arrives, execute the code, clean everything up, and reuse the worker.
This is where I'm currently stuck thinking about architecture.
I want SuperSand to eventually handle a LOT of small executions without needing ridiculous amounts of hardware. If a user runs something for several minutes, I don't necessarily want one worker sitting there occupied the entire time.
I've even been researching process checkpoint/restore so theoretically I could pause an execution, free the worker for something else, and resume it later.
I also considered going even further and doing runtime-level scheduling for JavaScript — basically controlling execution myself and giving different workloads execution time in smaller slices.
For JS I'm looking at QuickJS, mostly because spinning up Node/Bun for every tiny execution can eat a surprising amount of RAM.
I'm probably overthinking some of this 😅, but that's also part of why I'm building it. I want to understand how far I can push Linux processes/namespaces and how these execution platforms actually work underneath.
If you've worked on container runtimes, serverless infrastructure, Linux sandboxing, schedulers, CRIU/checkpointing, QuickJS, etc., I'd really like to hear your thoughts.
If you were trying to run thousands of small untrusted code executions on limited hardware, how would you approach the worker/scheduling architecture?
Also very interested in hearing what I'm doing wrong. 😅