Most serverless stacks still feel like tiny virtual machines—warm‑up delays, minimum billing, arbitrary limits. But a composition of unikernel infrastructure with Bun's performance‑first JavaScript runtime changes each of those constraints at once.
| Pain‑point | Typical Cloud FaaS | Impact |
|---|---|---|
| Cold start | 100 ms – 2 s | Latency spikes |
| Memory floor | 50 – 100 MB | Idle cost |
| Duration cap | 15 min (AWS), 10 min (GCP) | Workarounds |
| Runtime skew | Varies per provider | Migration friction |
The root cause is architectural: a full OS image inside a container inside a hypervisor—the exact opposite of "just run my code."
A unikernel is an application compiled with the kernel. No shell, no package manager, no unused drivers—just the code paths your service needs.
Bun rebuilds the Node.js developer contract on JavaScriptCore and Zig:
--compile --bytecode), shaving interpretation overheadunikernel boot × Bun startup → multiplicative win:
| Stage | Node + Container | Bun + Unikernel |
|---|---|---|
| Boot kernel | 150 ms | – |
| Start container | 300 ms | – |
| Runtime init | 200 ms | < 10 ms |
| Total cold start | 650 ms ‑ 2 s | 20 ‑ 30 ms |
Because memory pressure collapses, providers can densely pack instances → lower per‑request pricing and greener compute³.
server.ts
const port = process.env.PORT ?? 3000;
Bun.serve({
port,
fetch(req) {
return new Response(JSON.stringify(req), { headers: { 'content-type': 'application/json' } });
},
});
Kraftfile
spec: v0.6
name: bun-demo
runtime: base-compat:latest
labels:
cloud.unikraft.v1.instances/scale_to_zero.policy: "on"
cmd: ["/usr/bin/bun", "run", "/app/server.js"]
Build once → deploy; the platform emits a unikernel image ~ 3 MB.
Observed metrics on a t4g.small host:
bun install + test; most Node apps run unmodified.scale_to_zero.cooldown_time_ms to balance thrash vs. cost.Migration effort is measured in days, not sprints.
Serverless 2.0 will not be about larger functions or richer dashboards—it will be about removing hidden layers until code and CPU are virtually adjacent. Unikernels and Bun are early but tangible proof: performance, economics, and developer ergonomics can improve simultaneously.
The next wave of platforms will build these principles in by default; until then, rolling your own with Unikraft + Bun gives you today what others will call table‑stakes tomorrow.