WebAssembly (Wasm) is a binary instruction format designed for a stack-based virtual machine. Its primary goal is to enable high-performance applications on web pages. However, it’s not limited to the Web — Wasm makes no Web-specific assumptions and does not include Web-only features. As an open standard, it is intended to support any language across any operating system, and today, most popular languages already offer some degree of support.
"WebAssembly, that defines a portable, size- and load-time-efficient format and execution model specifically designed to serve as a compilation target for the Web." - Luke Wagner
WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime optimized for cloud-native, edge, and decentralized applications.
This project offers end-to-end code to test a Kubernetes-based application using the WasmEdge runtime.
The following table presents sample metrics taken from the 95th percentile of a single test run. These values may vary with each execution:
Metric Name | Description | Rust | Wasm |
---|---|---|---|
http_req_blocked | Time spent waiting for an available TCP connection before making the request. | 14.06ms | 3.55ms |
http_req_connecting | Time spent establishing a TCP connection to the remote host. | 13.79ms | 3.16ms |
http_req_receiving | Time spent receiving data from the remote host. | 16.04ms | 2.39ms |
http_req_sending | Time spent sending data to the remote host. | 7.14ms | 1.57ms |
http_req_waiting | Time spent waiting for the response (also known as "time to first byte" or "TTFB"). | 34.92ms | 126.93ms |
Note: Surprisingly, the response waiting time in the Wasm version is longer than in Rust.
The Vagrant tool can be used to provision an Ubuntu Focal virtual machine. It’s highly recommended to use the setup.sh script from the bootstrap-vagrant project to install the required Vagrant dependencies and plugins.
This script supports two virtualization providers — Libvirt and VirtualBox — which can be selected via the PROVIDER environment variable:
curl -fsSL http://bit.ly/initVagrant | PROVIDER=libvirt bash
Once Vagrant is set up, you can provision the virtual machine using:
vagrant up
This process may take a while, as it installs all dependencies and deploys Kubernetes within the VM.