Serverless
Cloudflare Workers
A serverless platform on Cloudflare's edge: V8 isolate code starts almost instantly worldwide.
What it is
Cloudflare Workers runs JavaScript, TypeScript and WebAssembly on Cloudflare nodes around the world. Instead of a container or a virtual machine it uses lightweight V8 isolates, so cold starts are practically unnoticeable.
Code is written on web standards: fetch, Request, Response. Workers connect to KV, Durable Objects, R2, D1 (SQLite), Queues, Workers AI. The workerd runtime is open source (Apache-2.0), while the platform itself is a commercial service.
There is a generous free tier, then billing by requests and CPU time.
Use it when
- APIs, redirects, A/B tests and authorization at the edge, close to the user.
- You need minimal cold start and global deployment with no region choice.
- Lightweight backends with R2, D1 and KV.
- Proxying and request transformation in front of the main backend.
Avoid it when
- The app depends on native Node.js modules or long computations.
- You need a classic relational setup with a large PostgreSQL database next to the server.
- The team needs full Node.js ecosystem compatibility without limits.
Key concepts
- V8 isolate
- A lightweight isolated sandbox inside one process that starts in milliseconds.
- Bindings
- Configured links between a Worker and resources: KV, R2, D1, Queues, variables and secrets.
- Durable Objects
- Stateful objects with a guarantee that one instance handles requests for a given key. Good for chats and counters.
- wrangler
- The official CLI for developing, running locally and deploying Workers.
- Edge
- Code runs on the node closest to the user rather than in a single region.
Example
Interview questions
1. Why do Workers start faster than Lambda?
They use V8 isolates inside an already running process rather than a separate container or micro-VM. Creating an isolate takes milliseconds, so the cold start is barely noticeable.
2. What are Durable Objects?
They are stateful objects addressed by key: all requests for that key land on one instance. This gives consistency for chats, counters and coordination without a separate database.
3. What are the limits of Workers?
Limits on CPU time and memory, partial Node.js API compatibility and no long background processes. For long tasks you use Queues or Workflows.
Comparisons with this technology
Related technologies
- CloudflareA global network with CDN, DNS, DDoS protection, plus Workers, R2 and D1 for running apps at the edge.
- AWS LambdaAn AWS service that runs functions in response to events and bills only for execution time.
- VercelA frontend platform from the creators of Next.js: Git deploys, a preview for every PR, serverless functions and edge.
- JavaScriptThe language of the web: runs in every browser, and on the server through Node.js, Deno and Bun.
- TypeScriptA superset of JavaScript with static types that compiles to plain JS.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).