WebAssembly in the Cloud
devops wasm
“If WASM+WASI existed in 2008, we wouldn’t have needed to create Docker.” Solomon Hykes’ quote sparked debate. Is WebAssembly the future of cloud computing?
What Is WASM
WebAssembly is a binary instruction format:
- Originally for browsers (near-native speed)
- Now running server-side (WASI runtime)
- Language-agnostic (Rust, Go, C++, etc.)
WASI (WebAssembly System Interface)
WASI extends WASM beyond browsers:
WASM (browser) → Can't access files, network, etc.
WASM + WASI → Can access system resources (sandboxed)
Why WASM for Cloud
Comparison to Containers
| Aspect | Containers | WASM |
|---|---|---|
| Cold start | 100ms-seconds | <1ms |
| Image size | 100s MB | <1MB |
| Isolation | Process level | Capability-based |
| Portability | Linux-centric | True cross-platform |
| Memory | Hundreds MB | KB-MB |
The Cold Start Advantage
Container: Start OS → Start runtime → Load app → Ready
WASM: Load module → Ready
For serverless, this matters enormously.
Hello WASM Cloud
Rust to WASM
// main.rs
fn main() {
println!("Hello from WASM!");
}
# Compile
rustup target add wasm32-wasi
cargo build --target wasm32-wasi --release
# Run with Wasmtime
wasmtime target/wasm32-wasi/release/hello.wasm
HTTP Server Example
use wasi_experimental_http::*;
#[no_mangle]
pub fn handle_request() -> i32 {
let response = Response::new()
.header("content-type", "application/json")
.body(r#"{"message": "Hello from WASM"}"#);
response.send();
0
}
WASM Runtimes
| Runtime | Focus | Language |
|---|---|---|
| Wasmtime | General, production | Rust |
| Wasmer | Developer friendly | Rust |
| WasmEdge | Cloud/Edge | C++ |
| Spin | Serverless apps | Rust |
| wasmCloud | Distributed apps | Rust |
Wasmtime
# Install
curl https://wasmtime.dev/install.sh -sSf | bash
# Run
wasmtime my_app.wasm
Spin (Serverless)
# Install
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash
# Create app
spin new http-rust hello-wasm
cd hello-wasm
# Build and run
spin build
spin up
Real Use Cases
Edge Computing
Request → CDN Edge → WASM function → Response
↓
No cold start overhead
Close to user
Cloudflare Workers and Fastly Compute use WASM.
Plugin Systems
// Host loads untrusted plugin safely
let engine = Engine::new(&config)?;
let module = Module::from_file(&engine, "plugin.wasm")?;
let instance = Instance::new(&mut store, &module, &imports)?;
// Call plugin function (sandboxed)
let result = instance.get_typed_func::<i32, i32>(&mut store, "process")?
.call(&mut store, input)?;
Multi-Language Microservices
Service A (Rust) → WASM → Same runtime
Service B (Go) → WASM → Same runtime
Service C (Python)→ WASM → Same runtime
One runtime, any language.
Serverless Functions
// Spin HTTP handler
use spin_sdk::http::{Request, Response};
use spin_sdk::http_component;
#[http_component]
fn handle_request(req: Request) -> Response {
Response::builder()
.status(200)
.header("content-type", "text/plain")
.body("Hello from Spin!")
.build()
}
# spin.toml
[[component]]
id = "hello"
source = "target/wasm32-wasi/release/hello.wasm"
[component.trigger]
route = "/hello"
Kubernetes + WASM
runwasi
Run WASM alongside containers:
apiVersion: v1
kind: Pod
metadata:
name: wasm-pod
spec:
runtimeClassName: wasmtime
containers:
- name: hello
image: ghcr.io/example/hello-wasm:latest
SpinKube
Deploy Spin apps to Kubernetes:
# Install operator
kubectl apply -f https://github.com/spinkube/spin-operator/...
# Deploy app
kubectl apply -f spin-app.yaml
Current Limitations
Language Support
| Language | Support | Maturity |
|---|---|---|
| Rust | Excellent | Production |
| C/C++ | Good | Production |
| Go | Good | Growing |
| Python | Limited | Experimental |
| JavaScript | Growing | Beta |
Ecosystem
- Fewer libraries than containers
- Tooling less mature
- Debugging harder
- Networking still evolving
Not All Workloads Fit
- Long-running processes (better with containers)
- Heavy I/O (network overhead)
- Complex system access (capability limitations)
When to Use WASM
Good Fit
- Serverless functions (cold start matters)
- Edge computing (size matters)
- Plugin systems (security matters)
- Multi-language apps (portability matters)
Stick with Containers
- Traditional web apps
- Database workloads
- Complex networking
- Legacy applications
The Future
WASM in the cloud is real but early:
- Cloudflare Workers (production)
- Fastly Compute (production)
- Fermyon Cloud (production)
- Kubernetes integration (growing)
The “Docker killer” narrative is overblown. WASM complements containers rather than replacing them.
But for the right use cases, it’s genuinely better.
WASM: Not a container replacement, but sometimes a better tool.