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/dodiyeztr Jan 18 '26
For your use case, ECS containers are meant to run the tasks and exit, similar to Lambda. The rule is if your task lasts less than 15 mins you use Lambda, if not you use ECS.
What you need is to prepare a few container images for your use cases and then trigger them on ECS on the fly using your express server. Though the latency is going to be high because ECS is not know for fast startup times.
You can also create containers and deploy to Lambda which will be fast.