跪拜 Guibai
← Back to the summary

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

Why can Cloudflare achieve millisecond-level cold starts while other cloud providers cannot?

If you have used traditional Serverless computing at scale in real commercial projects, you have definitely experienced an excruciating torment: Cold Start.

When your endpoint goes half an hour without a visit, the underlying cloud function automatically goes to sleep. If an unlucky user clicks a button at that moment, they might stare at a spinning loading icon on the screen for a full 3 to 5 seconds before the interface struggles to return data.

Countless backend engineers have resorted to all sorts of hacky workarounds to solve this 3-second delay: writing cron scripts to ping the endpoint every minute (the so-called keep-alive warm start), reserving a large number of idle concurrent instances.

But this is a massive engineering paradox: we embraced Serverless to save money, yet to fight cold starts, we end up spending money to keep those idle machines alive.

Until Cloudflare Workers burst onto the scene (a free-tier miracle 🤣🤣🤣), coldly throwing out a metric that defies convention: 0 milliseconds cold start.

Why, in the extremely capital-intensive field of cloud computing, are other giant cloud providers (like AWS Lambda, Alibaba Cloud) still struggling with cold starts of hundreds of milliseconds despite investing tens of billions, while Cloudflare Workers easily achieves extreme millisecond-level performance?

This is not a matter of who writes better code; this is a dimensional strike at the architectural level 🖐️.


Why is Traditional Serverless So Slow?

To understand why Cloudflare is fast, you must first understand why traditional Serverless is slow.

Traditional cloud functions (like AWS Lambda), to guarantee extremely strict multi-tenant security isolation, use micro virtual machines (MicroVMs, like Firecracker) or heavily stripped-down Docker containers at the bottom layer.

When a dormant cold request comes in, what is the cloud provider's machine frantically busy doing in the background?

ChatGPT Image 2026年7月21日 10_13_34.png

It must first cold-start a Linux operating system kernel on the physical machine. Then allocate isolated virtual memory and a network stack. Next, start a massive Node.js runtime process. Finally, load your business code into memory and execute it.

Even if this process has been optimized to the extreme by the giants, limited by the physical laws of OS startup, it inevitably consumes hundreds of milliseconds or even seconds. It's like wanting just a sip of water, but the cloud provider, for absolute security, forces you to make a new cup every time, or even build a new water dispenser on the spot.

This is the physical overhead of infrastructure 🫵.


V8 Isolates Flipped the Table!

How did Cloudflare break the deadlock? They looked at the traditional container architecture and flipped the table: we don't need the operating system anymore, nor the massive Node.js process.

They directly stripped out the V8 engine underlying the Google Chrome browser and deployed it across hundreds of global edge nodes.

In Cloudflare Workers, different users' code no longer runs in independent operating systems or processes, but in different Isolates within the same V8 process.

ChatGPT Image 2026年7月21日 10_20_59.png

What is an Isolate? You can think of it as a browser tab. When you open two different web pages in Chrome, they share the same underlying browser process, but their memory heaps and contexts are completely physically isolated.

When you deploy code to Workers and a cold request comes in, Cloudflare does not need to start any operating system. It only needs to instantly new an extremely lightweight Isolate context within the already permanently running V8 engine, then stuff your JavaScript code in to execute.

How long does this Isolate creation take? Less than 5 milliseconds.

For humans and typical network fluctuations, 5 milliseconds is even much shorter than a TCP handshake. In terms of perception, it is an absolute 0 milliseconds cold start.


But What Must You Sacrifice for Extreme Speed?

There is no free lunch in the business world. The reason Cloudflare achieves this insane cold start speed is at the cost of extremely strict development environment restrictions. This is the deep water that separates ordinary developers from edge architects.

If you are just a skilled worker writing Node.js business code every day, you will struggle to move an inch in the Workers environment.

Because there is no underlying Linux environment here. You cannot use the fs module to read and write disks, you cannot use child_process to spawn sub-processes, and you cannot even freely use those NPM native packages that depend on C++ extensions. You are extremely strictly locked into a sandbox of pure Web Standard APIs (like fetch, Streams).

Let's look at a highly representative piece of Cloudflare Workers gateway interception code:

// Abandon all Node.js dependencies, fully embrace Web APIs
export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
    // Code is instantly parsed and intercepted by V8, with zero physical overhead of container startup
    const url = new URL(request.url);
    
    // If no valid Token is carried, terminate the request directly at the edge node
    // Malicious traffic doesn't even have the qualification to touch your core data center origin
    const authHeader = request.headers.get('Authorization');
    if (!authHeader || authHeader !== `Bearer ${env.SECRET_TOKEN}`) {
      return new Response('Unauthorized Edge', { status: 401 });
    }

    try {
      // Must use the native fetch API to make origin requests
      const response = await fetch(`https://api.core-backend.com${url.pathname}`, {
        method: request.method,
        headers: request.headers,
      });
      
      // Bypass the extremely strict CPU time limit (usually only tens of milliseconds per request)
      // Offload time-consuming audit logging tasks to after the HTTP response is returned using ctx.waitUntil
      // This ensures the user's request is absolutely never slowed down by background logic
      ctx.waitUntil(this.logAnalytics(request, response.status));

      // Return a pure stream, with zero physical resistance
      return new Response(response.body, response);
    } catch (error) {
      return new Response('Edge Gateway Crash', { status: 500 });
    }
  },
  
  async logAnalytics(req: Request, status: number) {
    // Execute asynchronous background time-consuming tasks here, fully squeezing the idle compute power of the edge node
  }
}

Furthermore, you must face extremely strict CPU time limits (usually a single request is only allowed tens of milliseconds of CPU computation; once timed out, it is forcibly killed) and extremely cramped memory limits (usually around 128MB).

Those sloppy code practices on traditional servers, where you carelessly load hundreds of megabytes of data into memory at once for JSON conversion, won't survive even a second on an edge computing node 🫡.


Why Don't Other Cloud Providers Copy Cloudflare Workers?

It's not that their technology is inferior, but that their business positioning is completely different. Traditional cloud providers must guarantee that you can run not only JavaScript, but also Python, Go, and even ancient Java monolithic applications. To be compatible with an extremely complex enterprise ecosystem, they have no choice but to carry the heavy shell of an operating system and containers.

Cloudflare, as a company that started with CDN and security, chose from the very beginning to serve only lightweight, high-frequency, stateless edge logic with extreme restraint. But as compensation, it grants you response speeds that break physical limits and some free quotas.

dash.cloudflare.com_ab2c40f8d8fefbaf5a28177590642968_workers_plans.png

(If you have lightweight front-end projects, or want to freeload storage and databases, its free tier can fully meet your needs 😁, this is not an ad 👋)

That's all for today's good stuff, thank you everyone 🙏

Thank you everyone.gif

Comments

Top 1 of 2 from juejin.cn, machine-translated. The original thread is authoritative.

JohnYan

RAAS, Runtime as a Service, is that new? [snicker]

ErpanOmer

Not new, just out of curiosity.