Essa is an experimental stateful serverless programming framework based on WebAssembly.
This project was heavily insprired by cloudburst, which provides a "low-latency, stateful serverless programming framework". Essa differs from the original project in multiple ways:
- WebAssembly functions: Instead of requiring that the user-provided functions are written in Python, we use the WebAssembly format. WebAssembly — or "Wasm" for short — is a portable instruction format that aims to be as fast as native code, while being completely sandboxed. Multiple programming languages such as C/C++, Rust, Go, or C# can be compiled to it already. These properties make Wasm very suitable for running untrusted user functions in a serverless framework.
- Written in Rust: While the original
cloudburstis written in Python, we rely on the Rust programming language. In addition to Rust's memory safety guarantees and high performance, this choice has the advantage that we can easily use thewasmedge-sdkor thewasmtimecrate for running WASI-compatible WebAssembly functions. - Based on our
anna-rsproject: The originalcloudburstproject uses theannakey-value store for storing function state. While we follow that design, we instead use ouranna-rsport, which is written in Rust instead of C++ and communicates usingzenohinstead ofZeroMQ.
Note: This project is still in a prototype state, so don't use it in production!
This project contains several executables:
essa-function-executor: Allows to compile and execute a WebAssembly module and its functions. We useWasmEdgeas the default executor. By enabling the featurewasmtime_executor, we can usewasmtimeas the executor.essa-function-scheduler: Schedules function execution requests to function executors.essa-test-function: A WebAssembly module that can be run inessa. It shows how to perform function calls across nodes and how to share state between them.run-function: Helper executable to start a given WebAssembly module by passing it to a function scheduler.
The following libraries are provided to interact with the Essa framework in WebAssembly crates:
essa-api: Provides an interface toessafunctions, which can be used from WebAssembly modules written in Rust.essa-macros: Provides macros to automatically make Rust functions in WebAssembly modules compatible with theessafunction call ABI. Re-exported fromessa-api.
You need the latest version of Rust for building.
The build commands are:
cargo build --workspace --exclude essa-test-functionfor a debug buildcargo build --workspace --exclude essa-test-function --releasefor an optimized release build
After building, you can find the resulting executables under ../target/debug (for debug builds) or ../target/release (for release builds).
To run the test suite, execute cargo test. The API documentation can be generated through cargo doc --open.
In order to run essa-rs, you need to first initialize the anna-rs submodule through git submodule update --init.
For a quick demo, run cargo run -p essa-test-function --example local. This command will compile and start all necessary runtime nodes, compile the essa-test-function to WASM, and then run the compiled WASM module on the started essa-rs nodes. It is worth noting that in this demo, WasmEdge will be used as the default executor.
For a manual run, execute the following commands in different terminal windows:
-
Start an
anna-rsrouting node:cargo run --release --manifest-path anna-rs/Cargo.toml --bin routing -- anna-rs/example-config.yml -
Start an
anna-rsKVS node:cargo run --release --manifest-path anna-rs/Cargo.toml --bin kvs -- anna-rs/example-config.yml -
Start the
essa-rsfunction scheduler:cargo run --release -p essa-function-scheduler --bin function-scheduler -
Start an
essa-rsfunction executor node with ID0:- Use
WasmEdgeas the executor:
cargo run --release -p essa-function-executor -- 0- Use
wasmtimeas the executor:
cargo run --no-default-features --features wasmtime_executor --release -p essa-function-executor -- 0 - Use
-
Compile the
essa-test-functionto WASM and start it through therun-functionexecutable:cargo build --release -p essa-test-function --target wasm32-wasi cargo run -p essa-function-scheduler --bin run-function -- target/wasm32-wasi/release/essa-test-function.wasmThe output of the WebAssembly function is then shown in the console window of the
essa-function-executorprocess.
The above commands should result in the same output as the demo command mentioned at the beginning of this section.
Instead of using cargo run --release, it is of course also possible to first compile the executables as described in the Build section and then run them from the target/release folder.
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0). Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.