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:

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

AspectContainersWASM
Cold start100ms-seconds<1ms
Image size100s MB<1MB
IsolationProcess levelCapability-based
PortabilityLinux-centricTrue cross-platform
MemoryHundreds MBKB-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

RuntimeFocusLanguage
WasmtimeGeneral, productionRust
WasmerDeveloper friendlyRust
WasmEdgeCloud/EdgeC++
SpinServerless appsRust
wasmCloudDistributed appsRust

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

LanguageSupportMaturity
RustExcellentProduction
C/C++GoodProduction
GoGoodGrowing
PythonLimitedExperimental
JavaScriptGrowingBeta

Ecosystem

Not All Workloads Fit

When to Use WASM

Good Fit

Stick with Containers

The Future

WASM in the cloud is real but early:

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.

All posts