Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Lunatic is an Erlang-inspired runtime for WebAssembly

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

lunatic-solutions/lunatic

lunatic logo

 

Lunatic is a universal runtime forfast,robust andscalable server-side applications.It's inspired by Erlang and can be used from any language that compiles toWebAssembly.You can read more about the motivation behind Lunatichere.

We currently provide libraries to take full advantage of Lunatic's features for:

If you would like to see other languages supported or just follow the discussions around Lunatic,join our discord server.

Supported features

  • Creating, cancelling & waiting on processes
  • Fine-grained process permissions
  • Process supervision
  • Channel based message passing
  • TCP networking
  • Filesystem access
  • Distributed nodes
  • Hot reloading

Installation

If you have rust (cargo) installed, you can build and install the lunatic runtime with:

cargo install lunatic-runtime

OnmacOS you can useHomebrew too:

brew tap lunatic-solutions/lunaticbrew install lunatic

We also provide pre-built binaries forWindows,Linux andmacOS on thereleases page, that you can include in yourPATH.


And as always, you can also clone this repository and build it locally. The only dependency isa rust compiler:

# Clone the repositorygit clone https://github.com/lunatic-solutions/lunatic.git# Jump into the cloned foldercd lunatic# Build and install lunaticcargo install --path.

Usage

After installation, you can use thelunatic binary to run WASM modules.

To learn how to build modules, check out language-specific bindings:

Architecture

Lunatic's design is all about spawningsuper lightweight processes, also known as green threads orgo-routines in other runtimes. Lunatic's processes are fast to create, have a small memory footprintand a low scheduling overhead. They are designed formassive concurrency. It's not uncommon to havehundreds of thousands of such processes concurrently running in your app.

Some common use cases for processes are:

  • HTTP request handling
  • Long running requests, like WebSocket connections
  • Long running background tasks, like email sending
  • Calling untrusted libraries in an sandboxed environment

Isolation

What makes the last use case possible are the sandboxing capabilities ofWebAssembly. WebAssembly wasoriginally developed to run in the browser and provides extremely strong sandboxing on multiple levels.Lunatic's processes inherit these properties.

Each process has its own stack, heap, and even syscalls. If one process fails, it will not affect the restof the system. This allows you to create very powerful and fault-tolerant abstraction.

This is also true for some other runtimes, but Lunatic goes one step further and makes it possible to use Cbindings directly in your app without any fear. If the C code contains any security vulnerabilities or crashes,those issues will only affect the process currently executing the code. The only requirement is that the Ccode can be compiled to WebAssembly.

It's possible to give per process fine-grained access to resources (filesystem, memory, network connections, ...).This is enforced on the syscall level.

Scheduling

All processes running on Lunatic are preemptively scheduled and executed by awork stealing async executor. Thisgives you the freedom to write simpleblocking code, but the runtime is going to make sure it actually never blocksa thread if waiting on I/O.

Even if you have an infinite loop somewhere in your code, the scheduling will always be fair and not permanently blockthe execution thread. The best part is that you don't need to do anything special to achieve this, the runtime will takecare of it no matter which programming language you use.

Compatibility

We intend to eventually make Lunatic completely compatible withWASI. Ideally, you could take existing code,compile it to WebAssembly and run on top of Lunatic; creating the best developer experience possible. We're notquite there yet.

License

Licensed under either of

at your option.


[8]ページ先頭

©2009-2025 Movatter.jp