Skip to content

open-runtimes/open-runtimes

Repository files navigation

Open Runtimes ⚡️

open-runtimes-box-bg-cover


Discord Build Status Twitter Account

Runtime environments for serverless cloud computing for multiple coding languages, aiming to create a consistent and predictable open standard for writing cloud functions in containerized systems.

Features

  • Flexibility (WIP) - Designed to work with multiple orchestrators using different adapters. For now only Docker and Swarm are supported, Kubernetes support is planned.
  • Performance - Cold starts in less than ~100ms & executions in less than 1ms.
  • Wide Support - Supports 11 (and counting) different programming languages and 18 (and counting) different runtimes. Adding new ones is straight forward.
  • Open Source - Released under the MIT license, free to use and extend.
  • Ecosystem - Fast growing ecosystem of ready-to-use functions for easy reuse on different platforms.

Roadmap

  • Kubernetes Adapter - Native cloud support and easy deployment
  • Official CLI - Easy deployments
  • Catalog - Browse the open-runtimes functions ecosystem
  • Autoscaling - Automated scaling features based on hosts and runtime metrics

Images

Name Version Docker Hub Examples Pulls
C++ 2017 openruntimes/cpp:v3-17 Examples Docker Pulls
Dart 2.15 openruntimes/dart:v3-2.15 Examples Docker Pulls
Dart 2.16 openruntimes/dart:v3-2.16 Examples Docker Pulls
Dart 2.17 openruntimes/dart:v3-2.17 Examples Docker Pulls
Dart 2.18 openruntimes/dart:v3-2.18 Examples Docker Pulls
Dart 2.19 openruntimes/dart:v3-2.19 Examples Docker Pulls
Dart 3.0 openruntimes/dart:v3-3.0 Examples Docker Pulls
Dart 3.1 openruntimes/dart:v3-3.1 Examples Docker Pulls
Dart 3.3 openruntimes/dart:v3-3.3 Examples Docker Pulls
Deno 1.21 openruntimes/deno:v3-1.21 Examples Docker Pulls
Deno 1.24 openruntimes/deno:v3-1.24 Examples Docker Pulls
Deno 1.35 openruntimes/deno:v3-1.35 Examples Docker Pulls
Deno 1.40 openruntimes/deno:v3-1.40 Examples Docker Pulls
.NET 6.0 openruntimes/dotnet:v3-6.0 Examples Docker Pulls
.NET 7.0 openruntimes/dotnet:v3-7.0 Examples Docker Pulls
Java 8 openruntimes/java:v3-8.0 Examples Docker Pulls
Java 11 openruntimes/java:v3-11.0 Examples Docker Pulls
Java 17 openruntimes/java:v3-17.0 Examples Docker Pulls
Java 18 openruntimes/java:v3-18.0 Examples Docker Pulls
Java 20 openruntimes/java:v3-20.0 Examples Docker Pulls
Java 21 openruntimes/java:v3-21.0 Examples Docker Pulls
Kotlin 1.6 openruntimes/kotlin:v3-1.6 Examples Docker Pulls
Kotlin 1.8 openruntimes/kotlin:v3-1.8 Examples Docker Pulls
Kotlin 1.9 openruntimes/kotlin:v3-1.9 Examples Docker Pulls
Node.js 14.5 openruntimes/node:v3-14.5 Examples Docker Pulls
Node.js 16.0 openruntimes/node:v3-16.0 Examples Docker Pulls
Node.js 18.0 openruntimes/node:v3-18.0 Examples Docker Pulls
Node.js 19.0 openruntimes/node:v3-19.0 Examples Docker Pulls
Node.js 20.0 openruntimes/node:v3-20.0 Examples Docker Pulls
Node.js 21.0 openruntimes/node:v3-21.0 Examples Docker Pulls
PHP 8.0 openruntimes/php:v3-8.0 Examples Docker Pulls
PHP 8.1 openruntimes/php:v3-8.1 Examples Docker Pulls
PHP 8.2 openruntimes/php:v3-8.2 Examples Docker Pulls
PHP 8.3 openruntimes/php:v3-8.3 Examples Docker Pulls
Python 3.8 openruntimes/python:v3-3.8 Examples Docker Pulls
Python 3.9 openruntimes/python:v3-3.9 Examples Docker Pulls
Python 3.10 openruntimes/python:v3-3.10 Examples Docker Pulls
Python 3.11 openruntimes/python:v3-3.11 Examples Docker Pulls
Python 3.12 openruntimes/python:v3-3.12 Examples Docker Pulls
Python ML 3.11 openruntimes/python-ml:v3-3.11 Examples Docker Pulls
Ruby 3.0 openruntimes/ruby:v3-3.0 Examples Docker Pulls
Ruby 3.1 openruntimes/ruby:v3-3.1 Examples Docker Pulls
Ruby 3.2 openruntimes/ruby:v3-3.2 Examples Docker Pulls
Ruby 3.3 openruntimes/ruby:v3-3.3 Examples Docker Pulls
Swift 5.5 openruntimes/swift:v3-5.5 Examples Docker Pulls
Swift 5.8 openruntimes/swift:v3-5.8 Examples Docker Pulls
Swift 5.9 openruntimes/swift:v3-5.9 Examples Docker Pulls
Bun 1.0 openruntimes/bun:v3-1.0 Examples Docker Pulls

Architecture

Architecture

Load Balancer

The Load Balancer get requests for endpoints and responsible for balancing and scaling the requests between multiple hosts where runtime executors are available. This is the layer where you want to implement auto-scaling and keep track of which host has which runtimes available to allow wise spending of computing resources.

Executor

The Executor is responsible for starting runtimes (AKA cold starts), and directing requests, environment variables, and user inputs to each runtime. In addition, the Executor will also be responsible for managing timeouts, max runtime allowed in parallel, and cleanup of inactive runtimes in the chosen interval.

Adapter

The Adapter is a software layer component that interacts with the container orchestration engine to manage the compute runtimes.

Runtime

The Runtime is a containerized isolated environment to run user-provided code. The runtime is spinning an HTTP TCP server on startup from one of the supported languages and handles requests on demand. Multiple runtimes of the same function can potentially run on the same or multiple hosts.

Function

The Functions is a user provider packaged of code that is mounted to each Runtime and is executed inside the isolated environment. The package code should already be compiled and provided with all required dependencies.

Build

The Build is composed from a queue and set of workers, the build process receives the raw codebase from the filesystem or a VCS and compiles or packages it with all dependencies. The build help with providing the dev's Function as a ready-to-execute codebase for the Runtime.

Structure

All runtimes share a common basic structure, but each additionally adds runtime-specific files to properly support it's package manager.

.
├── src
│   ├── (runtime-specific, like index.js)
├── example
│   ├── (runtime-specific, like server.js)
├── helpers
│   ├── after-build.sh
│   ├── before-build.sh
│   ├── before-start.sh
│   ├── build.sh
│   └── start.sh
├── docker-compose.yml
├── Dockerfile
├── README.md
└── (runtime-specific, like package.json)
Name Description
src/ Contains source code of HTTP server of the runtime server
example/ Contains a sample function to demonstrate the usage of the runtime server
helpers/ Contains bash scripts that helps with simple build and start process. Can be ignored for more complex solution.
docker-compose.yml Configuration to easily run the example code with docker-compose up
Dockerfile Instructions to build a runtime, install it's dependencies and setup the runtime server. These images are usually based on official alpine or ubuntu.
README.md Runtime specific documentation

Structure of helpers/ directory follows:

Name Description
before-build.sh Mirroring of function code from mount directory to build directiry. Do changes inside build directory if needed.
after-build.sh Append .open-runtimes file, gzip file, and store into mount directory. Do post-build changes to build output if needed.
build.sh Shortcut combining before-build.sh, your custom build command (like npm install), and after-build.sh.
before-start.sh Extracting of function build from mount directory into server's directory. Do changes to server directory if needed.
start.sh Shortcut combining before-start.sh and your custom start command (like npm start)

Every request sent to any of the runtimes must have the x-open-runtimes-secret header. The value of this header has to match the value of environment variable OPEN_RUNTIMES_SECRET set on the runtime. All example scripts use secret-key as the key and we strongly recommend changing this key before production use.

Testing

We use PHP framework PHPUnit to test Open Runtimes. Every PR is automatically tested by Travis CI, and tests run for all runtimes.

Before running the tests, make sure to install all required PHP libraries:

docker run --rm --interactive --tty --volume $PWD:/app composer install

You also need to install jq:

brew install yq

To run test for a runtime, get runtime name (folder name) and execute below command:

sh tests.sh go-1.22

Replace go-1.22 with runtime name that you want to test

Contributing

All code contributions - including those of people having commit access - must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.

We truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the contribution guide.

Security

For security issues, kindly email us at security@appwrite.io instead of posting a public issue on GitHub.

Follow Us

Join our growing community around the world! See our official Blog. Follow us on Twitter, Facebook Page, Facebook Group , Dev Community or join our live Discord server for more help, ideas, and discussions.

License

This repository is available under the MIT License.