
When WebAssembly (Wasm) was first announced, it was hailed as the technology that would finally break JavaScript's monopoly in the browser. It allowed developers to compile C++, Rust, and Go into a binary format that ran at near-native speeds on the web.
In 2026, Wasm's most profound impact hasn't been in the browser - it's in the cloud. WebAssembly has evolved from a web technology into a universal, secure, and fast compute runtime that is replacing containers in latency-sensitive and multi-tenant environments.
This post goes hands-on: you'll compile Rust to WASI, embed a Wasm runtime in Python, build a sandboxed plugin system with Extism, and understand when Wasm actually beats containers.
The standard pitch is "Wasm is faster than containers." That's only partly true. Here's the accurate comparison:
| Docker Container | WebAssembly Module | |
|---|---|---|
| Startup time | 500ms–2s (cold) | < 1ms |
| Image size | 50 MB – 1 GB | 1 MB – 10 MB |
| Memory baseline | 30–100 MB | < 1 MB |
| Security model | Linux namespaces/cgroups | Capability-based sandbox |
| Language support | Any (via OS) | Any that compiles to Wasm |
| Networking | Full TCP/UDP stack | WASI sockets (preview 2) |
| Filesystem access | Bind mounts | Explicit capability grant |
The startup time difference is the critical one. A Docker container boot is gated by the Linux kernel setting up namespaces - you can't avoid it. A Wasm module instantiation is a memory allocation and a JIT compile, measured in microseconds. This is why Cloudflare Workers can run 50 million concurrent Wasm instances on their network.
Wasm originally had no I/O. It was a pure computation engine - it couldn't read files, open network sockets, or even get the current time without the host providing those capabilities explicitly.
WASI (WebAssembly System Interface) defines standardized system interfaces. WASI Preview 2 (stabilized 2024) introduced the Component Model - a type-safe ABI that lets Wasm modules from different languages interoperate.
When you compile a Rust program to wasm32-wasip2, you get a .wasm binary that runs on any WASI-compliant runtime (Wasmtime, WasmEdge, Wasmer) on any OS and architecture without modification.
# Install the WASI target
rustup target add wasm32-wasip2
# Create a simple HTTP handler
cargo new wasm-handler
cd wasm-handler
# Cargo.toml
[dependencies]
wasi = "0.13"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
// src/main.rs
use std::io::{self, Read, Write};
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Request {
name: String,
multiplier: u32,
}
#[derive(Serialize)]
struct Response {
message: String,
result: u64,
}
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let req: Request = serde_json::from_str(&input).unwrap_or(Request {
name: "world".to_string(),
multiplier: 1,
});
let response = Response {
message: format!("Hello, {}!", req.name),
result: fibonacci(req.multiplier as u64),
};
io::stdout()
.write_all(serde_json::to_string(&response).unwrap().as_bytes())
.unwrap();
}
fn fibonacci(n: u64) -> u64 {
match n {
0 => 0,
1 => 1,
_ => {
let mut a = 0u64;
let mut b = 1u64;
for _ in 2..=n {
let c = a + b;
a = b;
b = c;
}
b
}
}
}
cargo build --target wasm32-wasip2 --release
# Output: target/wasm32-wasip2/release/wasm-handler.wasm (< 500 KB)
# Run with wasmtime
echo '{"name":"developer","multiplier":30}' | wasmtime target/wasm32-wasip2/release/wasm-handler.wasm
# Output: {"message":"Hello, developer!","result":832040}
The resulting .wasm file runs on Linux x86, macOS ARM, Windows x86, and any edge PoP - identical binary, no recompilation.
You can use Wasm as a plugin runtime inside any host language. This is one of the most powerful patterns: your core application is Python, but performance-critical or user-submitted logic runs in sandboxed Wasm:
pip install wasmtime
# host.py
from wasmtime import Store, Module, Instance, Linker, WasiConfig
import json
def run_wasm_handler(wasm_path: str, input_data: dict) -> dict:
store = Store()
# Configure WASI capabilities - deny-by-default
wasi_config = WasiConfig()
# We do NOT grant filesystem or network access - pure computation only
store.set_wasi(wasi_config)
linker = Linker(store.engine)
linker.define_wasi()
module = Module.from_file(store.engine, wasm_path)
instance = linker.instantiate(store, module)
# The WASM module reads from stdin and writes to stdout
# For real production use, consider wasmtime's memory API for direct buffer passing
import subprocess
result = subprocess.run(
["wasmtime", wasm_path],
input=json.dumps(input_data).encode(),
capture_output=True,
timeout=5, # hard timeout - Wasm can't escape it
)
return json.loads(result.stdout)
result = run_wasm_handler(
"target/wasm32-wasip2/release/wasm-handler.wasm",
{"name": "Python host", "multiplier": 40}
)
print(result) # {"message": "Hello, Python host!", "result": 102334155}
The timeout=5 is enforced by the OS - a malicious Wasm module cannot bypass it. The module also cannot access the filesystem or network because WasiConfig didn't grant those capabilities.
Extism is the cleanest way to embed Wasm plugins in a host application. It handles the ABI complexity of passing strings/bytes between the host and Wasm.
cargo install extism-pdk
cargo new --lib my-plugin
cd my-plugin
# Cargo.toml
[lib]
crate-type = ["cdylib"]
[dependencies]
extism-pdk = "1"
serde = { version = "1", features = ["derive"] }
// src/lib.rs
use extism_pdk::*;
use serde::{Deserialize, Serialize};
#[derive(Deserialize)]
struct Input {
text: String,
max_words: usize,
}
#[derive(Serialize)]
struct Output {
summary: String,
word_count: usize,
}
#[plugin_fn]
pub fn summarize(input: Json<Input>) -> FnResult<Json<Output>> {
let words: Vec<&str> = input.text.split_whitespace().collect();
let truncated = words[..words.len().min(input.max_words)].join(" ");
Ok(Json(Output {
summary: if words.len() > input.max_words {
format!("{}...", truncated)
} else {
truncated
},
word_count: words.len(),
}))
}
cargo build --target wasm32-unknown-unknown --release
# host.py
import extism
import json
manifest = {"wasm": [{"path": "target/wasm32-unknown-unknown/release/my_plugin.wasm"}]}
with extism.Plugin(manifest) as plugin:
result = plugin.call(
"summarize",
json.dumps({"text": "WebAssembly is a portable compilation target...", "max_words": 5})
)
print(json.loads(result))
# {"summary": "WebAssembly is a portable compilation...", "word_count": 8}
The plugin runs in a Wasm sandbox. It cannot:
This is the pattern for safely executing user-submitted code at scale - each tenant's plugin runs isolated from all others.
Traditional serverless (AWS Lambda, Google Cloud Functions) suffers from cold starts because container init takes 500ms–2s. Wasm-native platforms eliminate this:
spin deploy ships a Wasm binary to their managed platform. No Dockerfile, no container registry.# Deploy a Rust Axum app to Fermyon Spin
spin new -t http-rust my-app
cd my-app
spin build
spin deploy
Stripe, Shopify, and Figma all allow plugins. The traditional approach: force users to write in a specific DSL or host an external webhook endpoint.
With Wasm: users write plugins in any language, upload a .wasm file, and your platform executes it in a sandbox. No infrastructure to manage, no trust boundary to enforce manually.
ONNX Runtime now ships a Wasm backend. You can run quantized ML models at the edge without spinning up a GPU server:
# Run inference at the edge
wasm-pack build --target web
# Deploy to Cloudflare Workers - inference runs in each PoP
WASI Preview 2's Component Model solves the historic pain point: Wasm modules could only exchange raw bytes. Passing a string from a Rust module to a Python module required manual pointer arithmetic.
The Component Model defines a type-safe interface description language (WIT - WebAssembly Interface Types). You describe the interface once:
// my-interface.wit
package my:plugin;
interface transform {
summarize: func(text: string, max-words: u32) -> string;
}
Then generate bindings in any language. A Rust plugin implementing summarize can be called from a Go host, a Python host, or a JavaScript host - with no manual serialization code.
Use Wasm when:
Stick with Docker when:
Wasm and Docker aren't mutually exclusive. Many production architectures use containers for the orchestration layer and Wasm for the compute layer inside those containers.
A startup is building a new serverless platform for highly concurrent, event-driven microservices. They need to minimize cold start times and resource overhead for millions of ephemeral functions. Given the comparison provided, which technology would be the most appropriate choice for their compute runtime and why?
Clean AI CLI logs, build cron expressions, decode JWTs, and calculate chmod permissions offline.

Exploring how WebAssembly (Wasm) and WASI 0.2 are redefining edge computing with microsecond cold starts, capability-based security, and Rust components.
Read more
Explore how to use WebAssembly on the server side with Wasmtime, WasmEdge, and Spin to build near-native speed, language-agnostic, and capability-sandboxed microservices - with real benchmarks vs Docker containers.
Read more
Accelerating browser compute 10x using Rust WebAssembly and 128-bit SIMD intrinsics: matrix operations, memory layout, and real-time audio/image processing.
Read more