lunatic 0.7 adds support for distributed process spawning and messaging
Hi rustaceans! 👋
I just pushed out a new release of lunatic with support for running distributed lunatic instances. You can check out the release notes here.
Lunatic is a WebAssembly runtime inspired by Erlang, written in Rust. However, it's also a great runtime for Rust compiled to WebAssembly. It may at first be a bit confusing; Why would you compile Rust code to bytecode and execute it inside of a runtime if you can just compile to native code right away?
There are a few features that would be hard, if not impossible, to achieve without bytecode:
Go/Erlang style green threads - lunatic allows you to spawn lightweight green threads that we call processes. We execute them on a work stealing multithreaded executor, but you don't need to color your functions with async. There is no way for code running on lunatic to block the runtime, even if you have functions that just run in an infinite loop. The runtime will preempt execution and only use non-blocking i/o underneath the hood.
Process isolation - lunatic processes don't share any memory or even syscalls. You can dynamically construct an environment to spawn processes into. This basically means that you can call a function, but limit the amount of memory/cpu it can use or just block certain syscalls (like establishing tcp connections). Even if this function calls into C code (provided that it can be compiled to wasm and linked together) the guarantees will hold.
Dynamic code loading - The runtime exposes all capabilities to code running inside of it. This means that you can dynamically load other WebAssembly modules from WebAssembly code and create new processes from it.
(NEW) Distributed instances - Now you can create multiple lunatic instances and link them together. They can run on different operating systems or CPU architectures. Because we deal with bytecode, you can execute functions anywhere inside of the cluster and the runtime is going to JIT compile it for the right architecture before running them.