/bounce

code execution engine (uses firecracker)

Primary LanguageGoMIT LicenseMIT

Bounce

Bounce is a scalable and fault-tolerant code execution engine that uses Firecracker for running code in isolated microVMs and RabbitMQ for scheduling them.

IMPORTANT NOTE: This was not made by me (@aleksrutins)! I just forked it, and then the original author (wyzlle) deleted their account. I have no clue how this thing works, but I'm hoping to figure it out.

Getting Started

  1. Install the following dependencies:

  2. Clone the repository:

git clone https://github.com/wyzlle/bounce.git .
  1. Start RabbitMQ and Postgres containers:
docker-compose up -d
  1. Start the worker (and agent):
./worker/start.sh
  1. Start the backend server:
cd backend
yarn install
yarn build
yarn start

API

Bounce exposes a simple API for submitting code and retrieving the results.

POST /exec

Submits code for execution. Accepts the following parameters in the request body:

  • code: the code to be executed (required)
  • language: the language the code is written in (required)
  • input: input to be provided to the code during execution (optional)

GET /exec/:id

Retrieves the results of a code execution by its submission ID. Returns a JSON object with the following properties:

  • stdout: the standard output produced by the code
  • stderr: the standard error produced by the code
  • exitCode: the exit code of the code

Examples

# submit code for execution
curl -X POST -H "Content-Type: application/json" -d '{"code": "print(input())", "input": "Hello World", "language": "py"}' http://localhost:3004/exec

# get execution results
curl http://localhost:3004/exec/<submission_id>

License

Bounce is licensed under the MIT License.