跪拜 Guibai
← All articles
Frontend · JavaScript · Programmer

V8 Isolates, Not Containers, Give Cloudflare Workers a 5 ms Cold Start

By ErpanOmer ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Cold starts are the hidden tax that makes serverless unpredictable and forces teams to run idle instances just to keep latency flat. Cloudflare’s Isolate model shows that sub-10 ms cold starts are possible when you drop OS-level isolation, but adopting it means rewriting backend code to fit a severely constrained Web API sandbox.

Summary

Traditional serverless platforms like AWS Lambda cold-start a Linux kernel, allocate virtual memory, and spin up a full Node.js runtime for every dormant function, a process that routinely takes hundreds of milliseconds. Cloudflare Workers replaces that entire stack with V8 Isolates — the same lightweight execution contexts Chrome uses to separate browser tabs. Because a V8 process is already running on every edge node, a cold request only needs to instantiate a new Isolate, which completes in under 5 ms.

The trade-off is a radically constrained runtime. Workers have no filesystem, no child processes, no native C++ addons, and a CPU budget capped at tens of milliseconds per request. Code must stick to Web Standard APIs like fetch and Streams, and any heavy work gets deferred via ctx.waitUntil after the response is sent.

Other cloud providers cannot adopt this model because their customers demand full Linux compatibility for Python, Go, and Java workloads. Cloudflare’s speed is a direct consequence of betting exclusively on lightweight, stateless JavaScript at the edge.

Takeaways
Cold starts in traditional serverless platforms require booting a Linux kernel, allocating virtual memory, and launching a runtime process, which takes hundreds of milliseconds even when optimized.
Cloudflare Workers runs code inside V8 Isolates — lightweight execution contexts that share a single process, similar to how Chrome isolates browser tabs — and creates a new Isolate in under 5 ms.
The Workers runtime has no filesystem, no child_process, and no native C++ addons; all code must use Web Standard APIs like fetch and Streams.
CPU time per request is capped at tens of milliseconds, and memory is typically limited to around 128 MB, forcing developers to write extremely lean request handlers.
Long-running background work must be offloaded with ctx.waitUntil, which runs after the HTTP response is returned so it never blocks the user.
Other cloud providers cannot replicate this architecture because their customers need full OS compatibility for runtimes like Python, Go, and Java, which forces them to keep the container model.
Conclusions

The cold-start problem in serverless is not a software optimization issue but an architectural one: as long as you boot an OS per function, physics imposes a floor of hundreds of milliseconds.

Cloudflare’s speed advantage is inseparable from its narrow scope. By refusing to support anything beyond JavaScript and Web APIs, it eliminates the entire category of overhead that general-purpose clouds must carry.

The Isolate model redefines what ‘cold’ means. When the V8 process is already warm and only the user’s code context is created fresh, the cold start becomes imperceptible to a human user.

Developers who treat Workers as a drop-in replacement for Node.js will hit the CPU and memory limits immediately. The platform rewards a different programming discipline: short-lived, stateless request handlers that defer everything non-critical.

The ctx.waitUntil pattern is a clever escape hatch that acknowledges the reality of edge computing: you have spare cycles after the response, but none to waste before it.

Concepts & terms
V8 Isolate
A lightweight execution context inside the V8 JavaScript engine that has its own heap but shares the same process with other Isolates. Chrome uses one Isolate per browser tab; Cloudflare Workers uses one per request handler, avoiding the cost of starting a new OS process.
Cold Start
The latency incurred when a serverless function is invoked after being idle, requiring the platform to allocate resources and initialize the runtime before executing code. In traditional serverless, this involves booting a container or microVM; in Workers, it means creating a new V8 Isolate.
ctx.waitUntil
A Cloudflare Workers API that allows asynchronous tasks to continue running after the HTTP response has been sent to the client. It is used to perform logging, analytics, or cleanup without adding latency to the user-facing request.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗