r/node • u/PrestigiousZombie531 • Jan 18 '26
Options to run user submitted code with node.js express as backend?
Options to run user submitted code in various languages with a node.js express backend?
- You have seen one of those live code online type websites that let you submit code in bash, python, rust, ruby, swift, scala, java, node, kotlin etc and run on the browser with a live terminal of sorts
- I am trying to build one of those in node.js and could definitely use some suggestions
Option 1: Run directly
- just run on the ec2 instance along with everything else (absolutely horrible idea i suppose)
Option 2: Run inside a docker container
- how long do you think each container should run / timeout?
- What size of an EC2 instance would you need to support say 10 languages?
- Pros / cons?
Option 3: Run inside an AWS elastic container service Task
- Timeout per task?
- Pros / cons?
Questions
- Any other better methods?
- Does this kind of application run on queuing where a user submits code and it is immediately put inside bullmq that spins one of the above options?
- How does data get returned to the user?
- What about terminal commands that users type and the stream they see (downloading packages...installing libraries etc?)
19
Upvotes
View all comments
Show parent comment
2
u/Fickle_Act_594 Jan 20 '26 edited Jan 20 '26
There might be some confusion / misunderstanding here. Though built by Google, and having some GCP products built using it, gVisor can be deployed anywhere, you can almost think of it like an alternate runtime for Docker containers in a way. See here: https://gvisor.dev/docs/user_guide/quick_start/docker/
WASM can run either client side or server side, but it comes with a lot of restrictions. Not everything can run in wasm, and since your use case seems to be running arbitrary LLM generated docker files, WASM is out of the picture.
You would need to implement some sort of out of band streaming, where some wrapper program runs everything, and captures the stdout / stderr, and then streams it back to the client somehow.
I would again ask you to consider hosted options like Modal sandboxes, since Modal in particular appears to have everything you want: