Cloudflare Containers now expose a public‑beta durable_object scheduling policy that lets a Durable Object decide which container image and instance size to launch at runtime, instead of relying on a single static configuration for the whole service.
New Durable Object Scheduling Policy
The policy shifts image and size selection from deployment time to execution time. A Durable Object receives the immutable image references prepared by Wrangler and can pass the desired reference together with an instance type when it starts a container via ctx.container.start. This change enables per‑object variability without redeploying the entire application.
Configuring Images and Instance Types
Define one or more named images in the Wrangler configuration. Both wrangler.jsonc and wrangler.toml support the same structure. For example:
{
"containers": [
{
"class_name": "AgentComputer",
"scheduling_policy": "durable_object",
"images": {
"base": {
"dockerfile": "./container/Dockerfile"
}
}
}
]
}or the equivalent TOML:
[[containers]] class_name = "AgentComputer" scheduling_policy = "durable_object" [containers.images.base] dockerfile = "./container/Dockerfile"
When the Durable Object runs, it can start a container with a specific image and size:
this.ctx.container.start({
image: this.ctx.container.images.base,
enableInternet: false,
instance: "standard-2"
});
The image field receives the immutable reference generated by Wrangler, and the instance field selects a size from the catalog (e.g., standard-2).
Operational Considerations
- Granular scaling: Each Durable Object can tailor resources to its workload, potentially reducing over‑provisioning.
- Deployment simplicity: Adding a new image only requires updating the Wrangler config; the runtime logic decides when to use it.
- Beta status: The feature is in public beta, so expect possible API adjustments and limited support guarantees.
- Observability: Track which images and instance sizes are being selected to detect unexpected patterns.
Security Implications
The image reference exposed through ctx.container.images is immutable, which limits tampering after build. However, because the selection happens at runtime, practitioners should ensure that only authorized Durable Objects can invoke start with arbitrary images or sizes. Review any custom logic that determines the image or instance type to avoid unintentionally exposing higher‑capacity instances or unvetted images.
Related CloudNinjas coverage: hands-on guides.
What This Means For Practitioners
Adopting the durable_object scheduling policy gives you per‑object control over container images and sizing, enabling more responsive resource allocation. Start by adding the policy to your Wrangler config, expose the image references in your Durable Object code, and implement simple validation around the chosen instance type. Monitor usage patterns during the beta period and be prepared to adjust logic if the platform evolves.
