As a platform lead on Cloudflare, how do you decide whether a workload runs in a Worker isolate, a Dynamic Worker or a Container?
answer
- default to the isolate
- name the requirement that forces a VM
- provisioned memory billed while running
- an image is a product to maintain
- no autoscaling yet
basics
~20 sDefault to a Worker isolate, use a Dynamic Worker for code loaded at runtime, and choose a Container only for a named need like a native binary or over 128 MB, accepting cold starts, an image and provisioned billing.
solid answer
~40 sI make the isolate the default and require a named reason to leave it. A Container is justified by a native binary, child processes, a full filesystem, an existing image or a working set beyond the isolate's 128 MB, as in our document converter. Its price is cold starts of seconds, an image to patch and build for `linux/amd64`, rollouts that are not atomic, no built-in autoscaling, and billing on provisioned memory and disk while instances run, plus the Worker and Durable Object in front. A Dynamic Worker suits tenant or generated JavaScript: millisecond starts, only the methods you pass, billed per unique Dynamic Worker per day. I'd standardise on `ctx.container` for new container code, keep the beta `durable_object` policy for sandboxes, cap instances, and review idle timeouts against the bill.
go deeper
Recall what each runtime can run: bundled JavaScript in an isolate, runtime-loaded code in a Dynamic Worker, any Linux image in a Container.
Explain the limits that force a move: 128 MB and no child processes in isolates, cold starts and provisioned billing in containers.
Design hybrids that send only the inputs needing a container to it, and size, cap and time out the container path.
Set the team rule that isolates are the default, define what justifies a container, and own the image, release and cost commitments that follow.
## Three runtimes, three cost shapes Cloudflare gives a team three places to run code beside a Worker, and the choice is a commitment the team pays for over time: | | Worker isolate | Dynamic Worker | Container | | --- | --- | --- | --- | | What runs | Your bundled JavaScript or WebAssembly | Code your Worker loads at runtime | Any Linux image built for `linux/amd64` | | Hard limits | 128 MB per isolate; no child processes or native add-ons | The isolate model, plus limits you can lower per load | Up to 4 vCPU, 12 GiB and 20 GB per instance | | Start | No image to boot | Milliseconds; `get()` reuses a warm one | Cold starts often 1 to 3 seconds | | Billing | Requests and CPU time | Requests, CPU, and each unique Dynamic Worker per day beyond 1,000 a month | Provisioned memory and disk, active CPU, per 10 ms, plus the Worker and Durable Object | | Plan | Free and Paid | Paid | Paid | | You maintain | Code | Code and the method surface | Code, the image and its rollouts | ## The default: an isolate The rule I would set: **every workload starts in a Worker isolate, and leaving it needs a named requirement.** Isolates start without booting an image, scale with requests and cost nothing while idle. Most API, routing, validation and transformation work fits. A Container is justified when the workload needs one of these: - a native binary or library, such as a document converter written for Linux; - child processes, a full filesystem or a specific runtime; - a working set beyond the isolate's 128 MB of memory; - an existing container image the team does not want to port. "It might be heavy one day" is not on the list. A requirement that only appears for some inputs often means a hybrid: the isolate handles small documents and sends large or exotic formats to a container. ## Where Dynamic Workers fit Dynamic Workers are for code that arrives at runtime: generated scripts, tenant plugins, templates. They start in milliseconds, see only the `env` and methods you pass, and can be cut off from the network. Their limits shape the design: a Worker request can have at most 4 distinct Dynamic Workers in flight (10 in a Durable Object), and every `load()` counts as a new Dynamic Worker for billing, so code that runs repeatedly should go through `get()` with a stable id. If the generated code needs Linux tools, it belongs in a container sandbox instead. ## What a Container commits the team to 1. **An image as a product.** Someone patches the base image, rebuilds it in CI with Docker, and stays under 50 GB of image storage per account; deleting old images can break a rollback to a Worker version that used them. 2. **Capacity by naming.** There is no built-in autoscaling. You choose per-entity names or a fixed pool through `getRandom()`, set `max_instances` (default 20) on the `default` policy, and enforce caps in code on the `durable_object` policy. 3. **Latency versus idle cost.** Inactivity timeouts trade cold starts against provisioned memory and disk billed while instances sit idle. 4. **Releases.** The Worker goes live before the image rolls out, so Worker and image changes must stay compatible across the rollout. 5. **API and policy choices.** New code uses `ctx.container`; the `Container` class is for existing applications. The `durable_object` scheduling policy, needed for per-instance images and snapshots, is in public beta and fixed at creation. ## Applying it to the document-conversion service - The Worker isolate authenticates, validates the upload, stores it in R2 and answers status requests. - A Durable Object per job keeps its state, and starts a `standard-1` container for formats that need the native converter. - Customer-supplied output templates run in a Dynamic Worker with `globalOutbound: null` and only the rendering methods they need. ## Revisit the decision when - the container's idle bill grows faster than its traffic; - users report waits that track cold starts; - built-in autoscaling ships, which would change the pool design; - the `durable_object` scheduling policy leaves public beta, or Sandbox SDK 0.x fixes end on 2026-12-31 for teams still on it.
- A team wants containers for every service because they already have Dockerfiles. How do you respond?Ask for the requirement each service has that an isolate cannot meet. Without one, a container adds cold starts, image upkeep, non-atomic rollouts and billing for provisioned memory while running, for no gain. Port services that fit isolates, and keep containers for native binaries, child processes or large working sets.
- How do you keep a container-backed path from dominating the bill?Pick the smallest instance type that fits measured peaks, keep inactivity timeouts short, cap concurrency with `max_instances` or code, and route only the inputs that need the container to it. Watch running time and idle periods per application, since memory and disk are billed while instances run, used or not.
- Picks containers by default because the team already has Dockerfiles.
- Assumes container instances autoscale like Worker isolates.
- Ignores that memory and disk are billed while a container idles.
- Calls load() for the same Dynamic Worker code on every request.
- Treats a Dynamic Worker as able to run native binaries.
Assumes Cloudflare's platform as of 2026-10-10: Containers and Dynamic Workers on Workers Paid, Dynamic Worker creation billed since 2026-05-26, no built-in container autoscaling, and the durable_object policy in public beta.