How Cloudflare Workers and AWS Lambda compare for a backend API in November 2026: isolates versus microVMs, CPU-time versus duration billing, limits, databases, queues and where your data lives.

Cloudflare Workers run JavaScript and TypeScript in V8 isolates on Cloudflare's network, close to whoever sends the request. AWS Lambda runs functions in Firecracker microVMs in one AWS region, next to RDS, SQS and the rest of an AWS account.
Both scale to zero and bill per use, and they stop looking alike once the API talks to a database. This guide compares them for a backend API.
Workers limits are from Cloudflare's Workers limits docs, and Lambda's from the Lambda quotas, all checked on November 20, 2026.
A Worker is an isolate inside a shared V8 process, which is why it starts so quickly and why it has a smaller box: 128 MB of memory, Web APIs such as fetch and Request in place of most of Node.js (with a compatibility flag for many Node built-ins), and no arbitrary binaries. A Lambda function is a small virtual machine with a full Linux userland, so it can run a native image library, a headless browser or a 2 GB machine learning model packaged in a container image. Code that depends on Node.js internals or native modules moves to Lambda unchanged, and moving it to Workers usually means replacing those dependencies.
Workers count CPU time, so a request that spends 5 ms computing and 300 ms waiting on an API is billed for 5 ms, and Cloudflare does not charge for wall time at all. Lambda bills duration, the full time from start to finish multiplied by the configured memory, plus a charge per million requests. For APIs that mostly wait on other services, Workers billing is lower, and for CPU-heavy work such as image processing the difference narrows or reverses, since Lambda can give that work more memory and CPU.
Lambda functions can run inside a VPC and reach RDS, ElastiCache and internal services over private IPs, with IAM controlling each permission, and a burst of invocations each opening a Postgres connection is the usual reason to add RDS Proxy. Workers reach an external Postgres over the internet, with Hyperdrive pooling connections and caching reads near the database, or use Cloudflare's own D1, KV, R2 and Durable Objects. Queues follow the same split, with Cloudflare Queues and Cron Triggers on one side and SQS, SNS and EventBridge on the other, so the deciding question is often where the rest of your data already lives.
Workers fit request handling at the edge: authentication checks, redirects, personalisation, API gateways in front of other services and APIs whose data lives in Cloudflare storage. Lambda fits backends that belong in an AWS account, such as event handlers for S3 uploads and SQS messages, internal APIs next to RDS and jobs that need more memory or a non-JavaScript runtime. Neither is a natural home for long-running consumers, WebSocket servers with lots of state or services that hold a database pool open, which is where containers come in.
Encore brings infrastructure from code, and instead of functions it deploys services that stay running, with their Postgres databases, Pub/Sub topics and cron jobs declared in the same application code. Per the AWS infrastructure docs, the services run on Fargate in your own AWS account, databases on RDS and Pub/Sub on SNS and SQS, so there is no 15-minute limit, no connection pool per invocation and no data outside your account.

Run in your terminal to get started locally.
An API that would be a Worker or a Lambda function plus a queue consumer, as one service:
// links/links.ts
import { api, APIError } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Topic, Subscription } from "encore.dev/pubsub";
const db = new SQLDatabase("links", { migrations: "./migrations" });
interface LinkClicked {
slug: string;
at: string;
}
const clicks = new Topic<LinkClicked>("link-clicked", {
deliveryGuarantee: "at-least-once",
});
// The hot path: one indexed lookup and a publish, no write on the request.
export const resolve = api(
{ expose: true, method: "GET", path: "/l/:slug" },
async ({ slug }: { slug: string }): Promise<{ url: string }> => {
const row = await db.queryRow<{ url: string }>`SELECT url FROM links WHERE slug = ${slug}`;
if (!row) throw APIError.notFound("no such link");
await clicks.publish({ slug, at: new Date().toISOString() });
return { url: row.url };
},
);
// The consumer that would be a separate Lambda function on SQS.
const _ = new Subscription(clicks, "count-click", {
handler: async (c) => {
await db.exec`
INSERT INTO daily_clicks (slug, day, clicks)
VALUES (${c.slug}, ${c.at}::date, 1)
ON CONFLICT (slug, day) DO UPDATE SET clicks = daily_clicks.clicks + 1
`;
},
});
-- links/migrations/1_init.up.sql
CREATE TABLE links (
slug TEXT PRIMARY KEY,
url TEXT NOT NULL
);
CREATE TABLE daily_clicks (
slug TEXT NOT NULL REFERENCES links(slug),
day DATE NOT NULL,
clicks BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (slug, day)
);
With encore run, Postgres starts locally and the subscription receives each click, and the Pub/Sub docs describe the retries and dead-letter queue the subscription gets on AWS. The counter is a plain increment, which counts a click twice if a message is redelivered, so a billing-grade count would store each click with an ID instead. The databases docs cover migrations and the connection pool the service keeps open, and the services docs explain how a directory becomes a deployable service.
An agent extending this API adds an endpoint or a subscription to the same file and runs the whole thing locally with a real Postgres, without a wrangler config, a function per handler or an SQS event source mapping to keep in step.
Best fit: Teams building backends on AWS that want always-running services with Postgres and queues in their own account, rather than functions with per-invocation limits.
Pick Workers for request handling that benefits from running close to users, fits in 128 MB and keeps its data in Cloudflare or calls APIs that are themselves global. Pick Lambda for event-driven code inside an AWS account, especially handlers for S3, SQS and EventBridge events and anything that needs more memory, a VPC or a runtime other than JavaScript. Pick Encore when the backend has a database and queues at its center and you want it running as services in your own AWS account.
Yes. For starting a request, Workers run in V8 isolates that start in milliseconds in a data center close to the user, while a Lambda function in one AWS region can take hundreds of milliseconds or more on a cold start. For requests that spend most of their time querying a database in one region, the database round trip often matters more than the start time.
Workers get 128 MB of memory per isolate and a capped amount of CPU time per invocation, and they run JavaScript, TypeScript and WebAssembly. Lambda functions get up to 10,240 MB, run for up to 15 minutes, support container images up to 10 GB and many runtimes, and can run inside a VPC next to RDS.
Workers bill for requests and CPU time, so time spent waiting on a database or an API is not charged. Lambda bills for requests and for duration multiplied by the memory size, so a function that waits 800 ms on a slow API pays for those 800 ms.
Encore lets you declare services, Postgres databases and Pub/Sub topics in application code, and deploys them as always-on services with RDS and SNS/SQS in your own AWS account. That removes the 15-minute limit and connection pooling concerns of Lambda while keeping the data in your AWS account.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.