🚀 Install WasmEdge
🤖 Build and contribute to WasmEdge
⌨️ Run a standalone Wasm program from CLI or Node.js or Golang or CRI-O / Docker
💭 Deploy a Wasm function as a web service (FaaS)
🛠 Embed a user-defined Wasm function in a SaaS platform
🔩 Embed a Wasm function in your Node.js web app
🔌 Embed a Wasm function in your Golang app
🔗 Deploy a Wasm function as a blockchain smart contract
WasmEdge (previously known as SSVM) is a high-performance WebAssembly (Wasm) VM optimized for Edge Computing, including Edge Clouds and Software Defined Vehicles. In its AOT mode, WasmEdge is the fastest Wasm VM on the market today.
WasmEdge is an official sandbox project hosted by CNCF (Cloud Native Computing Foundation).
The most important use case for WasmEdge is to safely execute user-defined or community-contributed code as plug-ins in a software product (e.g., a SaaS, a car OS, an edge node, or even a blockchain node). It enables third-party developers, vendors, suppliers, and community members to extend and customize the software product. With WasmEdge, a software product could become a host platform.
WasmEdge provides a well-defined execution sandbox for its contained Wasm bytecode program. The bytecode program cannot access operating system resources (e.g., file system, sockets, environment variables, processes) without explicit permissions from the VM's runner. The runner specifies the system resources the VM can access in the VM's configuration options upon starting up (a.k.a capability-based security model).
WasmEdge also provides memory protection for its contained bytecode program. If the program attempts to access memory outside of the region allocated to the VM, the VM will terminate with an error message.
WasmEdge and its contained wasm program can be started from the CLI as a new process, or from a existing process. If started from an existing process (e.g., from a running Node.js or Golang program), the VM will simply run inside the process as a function. It is also possible to start a WasmEdge VM instance as a thread. Currently, WasmEdge is not yet thread-safe, meaning that VM instances running in different threads in the same process will potentially be able to access each other's memory. In the future, we plan to make WasmEdge thread safe.
A major use case of WasmEdge is to start an VM instance from a host application. In general, you can use the WasmEdge C API to do so. You can also refer to the quick start guide of the WasmEdge C API.
However, the Wasm spec, and the WasmEdge C API, only supports very limited data types as input parameters and return values for the contained Wasm bytecode functions. In order to pass complex data types, such as a string of an array, as call arguments into the contained function, you should use the bindgen solution provided by the rustwasmc toolchain.
We currently supports bindgen in the Node.js host environment and in Golang environment. We are working on supporting interface types in place of bindgen for future releases.
Sometimes, the Wasm bytecode alone could prove too limiting for some applications. WasmEdge provides a host function API that allows Wasm bytecode programs to load and call native library functions from the underlying host operating system.
The host functions break the Wasm sandbox. But the sandbox breaking is done with explicit permission from the system’s operator.
In fact, the extensions to WasmEdge are implemented using native host functions. For example, the Tensorflow extension allows Wasm bytecode to make calls to the native Tensorflow library functions.
With the WasmEdge C API, you can write a program to start, stop, and manage WasmEdge VM instances in your own applications. For example,
- When WasmEdge functions are embedded in Node.js or in Slack, the VM is launched by the application when there is an incoming request.
- When WasmEdge functions are plugged into a data flow engine like YoMo, the VM is launched when a new data point flows through the system.
- As an OCI compliant runtime, WasmEdge applications could be managed by Docker tools such as CRI-O and Docker Hub. See how We are currently working on Kubernetes support.
WasmEdge supports optional WebAssembly features and proposals. Those proposals are likely to become official WebAssembly specifications in the future. WasmEdge supports the following proposals.
- WASI (WebAssembly Systems Interface) spec. WasmEdge has supported the WASI spec for WebAssembly programs to interact with the host Linux operating system securely.
- Reference Types. It allows WebAssembly programs to exchange data with host applications and operating systems.
- Bulk memory operations. The WebAssembly program sees faster memory access and performs better with bulk memory operations.
- SIMD (Single instruction, multiple data). For modern devices with multiple CPU cores, the SIMD allows data processing programs to take advantage of the CPUs fully. SIMD could significantly enhance the performance of data applications.
Meanwhile, the WasmEdge team is exploring the wasi-socket proposal to support network access in WebAssembly programs.
A key differentiator of WasmEdge from other WebAssembly VMs is its support for non-standard extensions. The WASI spec provides a mechanism for developers to extend WebAssembly VMs efficiently and securely. The WasmEdge team created the following WASI-like extensions based on real-world customer demands.
- Tensorflow. Developers can write Tensorflow inference functions using a simple Rust API, and then run the function securely and at native speed inside WasmEdge.
- Other AI frameworks. Besides Tensorflow, the Second State team is building WASI-like extensions for AI frameworks such as ONNX and Tengine for WasmEdge.
- Storage. The WasmEdge storage interface allows WebAssembly programs to read and write a key value store.
- Command interface. WasmEdge enables webassembly functions execute native commands in the host operating system. It supports passing arguments, environment variables, STDIN / STDOUT pipes, and security policies for host access.
- Ethereum. The WasmEdge Ewasm extension supports Ethereum smart contracts compiled to WebAssembly. It is a leading implementation for Ethereum flavored WebAssembly (Ewasm).
- Substrate. The Pallet allows WasmEdge to act as an Ethereum smart contract execution engine on any Substrate based blockchains.
WasmEdge enables software products to be extended and customized by their users. With WasmEdge, any software product can build a developer ecosystem. Here are some specific use cases from our customers and partners.
- A Jamstack application consists of a static frontend with JavaScript to interact with backend APIs. It is a very popular modern web application architecture. The frontend static files can be distributed over CDNs, and the backend functions can be hosted on edge nodes. The cloud-based WasmEdge hosts secure and high performance backend serverless functions for Jamstack apps especially on the Edge cloud.
- SaaS applications often need be tailored or customized “on the edge” for customer requirements. With WasmEdge, SaaS applications can directly embed and execute user-submitted code as part of the workflow (eg as a callback function to handle events from the SaaS app).
- WasmEdge is adapted to run on a variety of embedded and real time operating systems for edge devices. That allows developers to write high performance applications once, in Rust or C, and run them safely on many edge device platforms.
- Example: RISC-V stack from RIOS Lab.
- Ongoing: Porting WasmEdge to the SeL4 real-time OS
- Upcoming: WasmEdge could be used as a RTOS code runtime for software modules in autonomous cars.
- Blockchain smart contracts are user submitted code executed by all nodes in the network. WasmEdge is a smart contract execution engine on leading blockchain projects.
If you would like to contribute to the WasmEdge project, please refer to our CONTRIBUTING document for details. If you are looking for ideas, checkout our wish list!
If you have any questions, feel free to open a GitHub issue on a related project or to join the following channels:
- Mailing list: Send an email to [email protected]
- Slack: Join the #WasmEdge channel on the CNCF Slack
- Twitter: Follow @realwasmedge on Twitter