Cloudflare has announced the public beta of its new container service, enabling developers to run containers on its global network. The service allows users to deploy Docker containers to run workloads difficult to support on the serverless computing platform Workers, such as media and data processing at the edge.
According to the documentation, Containers is deeply integrated with Workers and built on Durable Objects, Cloudflare’s building block for stateful applications and distributed systems. The service enables customers to run resource-intensive applications that require parallel CPU cores, applications and libraries that need a full filesystem or specific runtime environment, and existing applications distributed as container images.
In a recent article, Mike Nomitch, product manager at Cloudflare, and Gabi Villalonga Simón, software engineer at Cloudflare, explained how Containers work and how they can be used in various scenarios, including as API gateways, service mesh, or orchestrators:
Not only do Durable Objects allow you to have fine-grained control over the Container lifecycle, the whole Workers platform allows you to extend routing and scheduling behavior as you see fit. Workers provide programmable ingress logic from over 300 locations around the world. In this sense, they provide similar functionality to an API gateway (…)
Among workloads where Workers fall short, Containers can run user-generated code in any language, execute CLI tools that need a full Linux environment, or port applications from other providers without major rewrites. Nomitch and Villalonga Simón add:
Routing to containers is enabled using under the hood (…) Each Durable Object acts as a programmable sidecar that can proxy requests to the container and manages its lifecycle. This allows you to control and extend your containers in ways that are hard on other platforms.
Source: Cloudflare blog
Cloudflare says some customers are already running thousands of containers, but the public beta limits users to a total of 40 GiB of memory and 40 vCPUs for concurrent instances.
Feedback on Reddit has been mostly positive. Mehmet Özgür Ersoy, director at modbe, tested a gateway architecture for NestJS and Next.js on the new platform and wrote:
The idea of combining the familiar world of Docker containers with Cloudflare’s vision of “simple, global, and programmable” computing opened up all kinds of new possibilities (…) I’m excited to see how this technology will reshape how we think about serverless architectures.
Cloudflare Containers Dashboard. Source: Cloudflare blog
Some features remain unavailable in the public beta, including global autoscaling and latency-aware routing. The team also plans to introduce more ways for Containers and Workers to communicate. They write:
We will be adding more ways for your Worker to communicate with your container and vice versa. We will add an exec command to run shell commands in your instance and handlers for HTTP requests from the container to Workers. This will allow you to more easily extend your containers with functionality from the entire developer platform, reach out to other containers, and programmatically set up each container instance.
Currently, only three instance sizes (dev, basic, and standard) are available, billed per 10ms of active runtime. Costs vary based on memory, disk, and CPU usage, and charges begin when a request is sent to the container or when manually started.
Cloudflare Containers is available in beta for all developers on paid plans, and a free tier is included.