Giter Site home page Giter Site logo

forkkit / lunatic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lunatic-solutions/lunatic

0.0 0.0 0.0 2.58 MB

Lunatic is an Erlang inspired runtime for WebAssembly

Home Page: https://lunatic.solutions

License: Apache License 2.0

Rust 95.79% WebAssembly 3.44% Shell 0.77%

lunatic's Introduction

Lunatic logo

ย 

Lunatic is a universal runtime for fast, robust and scalable server-side applications. It's inspired by Erlang and can be used from any language that compiles to WebAssembly. You can read more about the motivation behind Lunatic here.

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 (partial)
  • Hot reloading

Installation

We provide pre-built binaries for Windows, Linux and macOS on the releases page.


On macOS you can also use Hombrew:

brew tap lunatic-solutions/lunatic
brew install lunatic

To build the project from source you will need to have rustup installed:

# Install Rust Nightly
rustup toolchain install nightly
# Clone the repository and all submodules
git clone https://github.com/lunatic-solutions/lunatic.git
# Jump into the cloned folder
cd lunatic
# Build and install Lunatic
cargo +nightly install --path .

Architecture

Lunatic's design is all about spawning super lightweight processes, also known as green threads or go-routines in other runtimes. Lunatic's processes are fast to create, have a small memory footprint and a low scheduling overhead. They are designed for massive concurrency. It's not uncommon to have hundreds 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 of WebAssembly. WebAssembly was originally developed to run in the browser and provides extremely strong sandboxing on multiple levels. Lunatic's processes inherit this properties.

Each process has their own stack, heap and even syscalls. If one process fails it will not affect the rest of 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 C bindings 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 C code 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 a work stealing async executor. This gives you the freedom to write simple blocking code, but the runtime is going to make sure it actually never blocks a thread if waiting on I/O.

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

Compatibility

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

License

Licensed under either of

at your option.

lunatic's People

Contributors

akegalj avatar benstiglitz avatar bkolobara avatar grippy avatar imor avatar rusch95 avatar tuxiqae avatar withtypes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.