WebAssembly (Wasm) promises to change the nature of web applications. However, we should take a look at the needs of the apps decoupled from the browser.
Enter open source NGINX Unit. Unit is an application runtime for web apps and APIs. It handles the HTTP(S) front end, request routing and serving of assets, including the hand-off of dynamic requests. In short, Unit decouples the HTTP server from the application process. And it’s an excellent fit for Wasm’s sandboxed execution and linear memory byte streams.
2. 2
WebAssembly (abbreviated Wasm) is a binary
instruction format for a stack-based virtual
machine.
Wasm is designed as a portable compilation
target for programming languages, enabling
deployment on the web for client and server
applications.
• orders of magnitude smaller than container images
• entirely portable across OS and CPU architectures
• with incredibly low startup latency
• capable of running tens of thousands of requests per second
• capable of running anywhere
• from tiny devices such as Raspberry Pis, in Docker
Desktop, Kubernetes, your desktop or cloud
00 Section Header
What is WebAssembly https://webassembly.org/
🤔
3. 3
What is a Stack-Based-Virtual Machine
Set of Instruction-Types
Instructions: The What and
How
The Program
13. 13
00 Section Header
WebAssembly on NGINX Unit
unitd: app
NGINX Unit
unitd: router
shared memory
HTTP context HTTP context
Wasmtime
.wasm module
Initialize & communicate over
linear memory
14. 14
Linear Memory in a Nutshell for non trivial data types
00 Section Header
Host Wasm-Module
Init
Act
Response
Requesting allocation of Memory for X bytes!
Returning a pointer to the begin of the Memory Page
Put rawBytes in Linear Memory
Call the exported Module Function (e.g. http_request_handler)
Returning a Pointer to the Memory Page with the Response
data and its length
Free
Finished Processing. Free Linear memory
🎮
Control over
its’ linear memory
18. Developer experience is king, but…
This only works if we have universal portability
WASI-HTTP must ensure separation of concerns
The innovation will follow
This is just the beginning
🤓