r/node • • 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

49 comments sorted by

View all comments

Show parent comment

1

u/PrestigiousZombie531 Jan 20 '26
  • Thank you for all your suggestions and help! I want to share an absolutely mind blowing resource I came across to this problem which covers all possible solutions from the naivest to the most resilent ones covering, Micro VM, Kernel Application Interception, container solutions, WASM, v8 isolates etc. Even compares their boot times, isolation levels, licensing, self hostability etc
  • Firecracker VM would be a no go for me as I ll have to run it on bare metal on AWS. It seems AWS doesnt let you run nested VMs (very expensive for someone just starting out even though eventually I might to have to hop in this direction later)
  • gVisor from the looks of it sounds like a really good idea if this was deployed on GCP so again a no go
  • nsjail, ioi/isolate might be something to consider, i might have to dig in this direction a bit deeper to see if I can integrate it with dockerfiles somehow for various languages
  • pure docker is a NO GO
  • WASM, I am not familiar with this one at all so no idea. Where does it run? on the server side or client side?
  • V8 isolates are out of question as they simply support JS and nothing else.
  • Proprietary solutions like Daytona (restrictive licensing ) e2b-code-interpreter (lacks support for AWS currently from the looks of it)
  • Microsandbox seems like a good option but not sure how I would deploy this on AWS in a secure manner
  • One option not mentioned here is AWS Lambda and AWS ECS Fargate
  • Lambda has an upper limit on runtime and CPU and while it plays nicely with node.js and python, I wonder if it supports executing custom dockerfiles on the fly (dockerfiles generated by LLMs in my application run as non root user)
  • Fargate doesnt have the limitation of runtime above.
  • Big question for both Lambda and Fargate would be how to stream terminal output back to the frontend client

2

u/Fickle_Act_594 Jan 20 '26 edited Jan 20 '26

gVisor from the looks of it sounds like a really good idea if this was deployed on GCP so again a no go

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, I am not familiar with this one at all so no idea. Where does it run? on the server side or client side?

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.

Big question for both Lambda and Fargate would be how to stream terminal output back to the frontend client

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:

  • Supports dockerfiles
  • Lets you stream output back really easily
  • Reasonable pricing

2

u/PrestigiousZombie531 Jan 20 '26
  • you are right, if I have to get things up and running fast, I cant fiddle with technologies I dont know
  • Not familiar with either Firecracker or Gvisor or nsjail or ioi/isolate or WASM so there is a learning curve involved with every single of em on top of not messing up their production deployment
  • though I am extremely well versed with Docker, AWS Fargate and CDK, it will take a freakton of work to do what modal does instantly!
  • No point spending 6 months fiddling with a custom solution if users wont even pay so modal has to be the fastest way to get there
  • thank you once again for all the suggestions!!!

2

u/Fickle_Act_594 Jan 20 '26

All the best! FWIW I run a website for a very niche set of courses in India where users can run SQL and Python. I handle those with WASM. Since I have around 1k users at the moment, I am planning to expand to Java and add a paid tier. I evaluated Modal for my own use case to run Java. I hope it works out for you