My default · Cloudflare · Edge primitive

Cloudflare Workers

The edge primitive. It sits between your users and your real backend, and it's very, very good at that.

I frame Workers as an infrastructure primitive, not a business-logic platform. My business logic sits next to Postgres in a VPC and reacts to AWS events, and a Worker can reach neither.

What Workers do brilliantly is everything between the user and that backend. The rule of thumb: if it takes a few milliseconds of CPU, doesn't need the VPC, native modules or AWS events, and sits in front of your backend, it's a Worker. Otherwise it's Lambda.

Use it when

  • LLM streaming proxy: hide your API key, check the user's budget, stream tokens back. Waiting on the model costs nothing.
  • Sudden spikes: no ramp-up limit and no requests-per-second quota. Absorb a flash sale at the edge and pass only real orders to AWS.
  • Edge front door: JWT checks, rate limits, bot and geo rules, redirects, A/B routing in front of an AWS origin.
  • Webhook receivers (Stripe, GitHub) that must answer instantly, even if hit three times a month.
  • Huge streamed downloads and uploads: no response size limit.
  • The WebSocket entry point for Durable Objects.
  • Small glue that must run untouched for years: old compatibility dates are supported forever, so there are no forced runtime upgrades.

Don't use it when

  • Business logic that needs your private Postgres, AWS events or IAM. Keep that on Lambda.
  • Native modules (sharp, Chromium, Prisma's engine), child_process, worker_threads, or more than 128 MB of memory.
  • Strict Australian data residency: Workers run wherever the request lands.
  • Enterprise clients who need an SLA: the $5 plan has none.

Pricing

$5 a month per account, including 10M requests and 30M CPU-ms. Then $0.30 per million requests and $0.02 per million CPU-ms. Billed on CPU time only: waiting is free. No egress charges.

Gotchas, with fixes

Gotcha: It's not full Node.js. Most pure-JavaScript npm packages work, but there are no native modules and child_process, worker_threads, cluster and vm are stubs.

Fix: Treat Workers as the layer in front of your backend. If a Worker grows into business logic that needs these, move it to Lambda Web Functions.

Gotcha: Memory is fixed at 128 MB per isolate.

Fix: Stream instead of buffering. Anything heavy goes to Lambda.

Gotcha: Calling AWS from a Worker means storing access keys: there's no IAM role.

Fix: Use narrowly scoped keys in Workers secrets, or call an AWS endpoint (function URL with signed requests) instead of AWS APIs directly.

Gotcha: Cron triggers are UTC only.

Fix: Convert schedules to UTC, or schedule in AWS with EventBridge Scheduler.

Gotcha: Workers Logs bills per log event until 30 November 2026 (20M included, then $0.60 per million). Five console.log lines per request multiplies the bill by five.

Fix: Log one structured object per request. From 1 December 2026 billing moves to $0.25/GB, cheaper than CloudWatch in Sydney ($0.67/GB).

Provisioning

Official Pulumi package · Official Terraform provider

@pulumi/cloudflare (WorkersScript, or the newer Worker / WorkerVersion / WorkersDeployment resources, beta). Pulumi doesn't bundle your code: build with Wrangler, deploy the output with Pulumi. Pick one owner per Worker.

Instead, consider

  • AWS Lambda Anything touching the VPC, AWS events or heavy compute.
  • Lambda Web Functions A Worker that grew into business logic and needs full Node.js or an IAM role.

Worked examples

Where it fits

  • An API for my app: Pick 04.

    In front, if users are global or traffic is huge (auth, rate limits, caching).

  • An AI chat or LLM feature: Pick 01.

    The proxy. Hides your key, enforces per-user budgets, streams tokens. Waiting is free.

  • Something live that many people watch at once: Pick 01.

    The door. Checks the login and routes each socket.

  • A traffic spike I can see coming: Pick 01.

    The shock absorber. Workers start in milliseconds at any traffic, with no ramp-up and no concurrency quota, so 0 to 5,000 requests a second just works. Lambda scales fast but in steps: at most 1,000 new instances per 10 seconds per function, capped by the account default of 1,000, each one cold-starting. Junk is rejected at the edge.

  • Logs without a shocking bill: Pick 04.

    Workers Logs moves to $0.25/GB on 1 December 2026.

  • Sign-in and identity: Pick 04.

    Verifies the tokens at the edge, from either one.

Sources

Last reviewed by Nicolas Dao

Want this stack in your AWS account?

Cloudless Labs is a Sydney consultancy. We migrate on-premises systems to AWS, build serverless apps on this stack, and coach teams to ship with Claude Code and Codex.

Contact Us

For general inquiries, please contact us at:

For e-learning capabilities, please contact: