Containers are available in public beta for simple, global, and programmable compute

Gabi Villalonga Simón
9 min readintermediate
--
View Original

Overview

Cloudflare has launched Containers in public beta, allowing users on paid plans to run various applications alongside Workers. This integration simplifies deployment, enhances global scalability, and provides programmability for container instances, enabling developers to create more powerful applications.

What You'll Learn

1

How to deploy a Container-enabled Worker using Cloudflare's wrangler

2

Why using Containers with Workers can enhance application performance and scalability

3

How to configure container settings such as default port and image in wrangler.jsonc

4

When to use Containers versus Workers for specific application needs

Key Questions Answered

What are Cloudflare Containers and how do they work?
Cloudflare Containers allow users to run applications alongside Workers, providing a global deployment model without managing multiple configurations. They are programmable and can be spun up on-demand, enabling developers to leverage various programming languages and tools for backend services, media processing, and more.
How can developers configure a Container in Cloudflare?
Developers can configure a Container by using the Container class in their Worker code and specifying settings in wrangler.jsonc, such as the default port and image to use. This setup allows for easy routing of requests to unique container instances based on user-defined IDs.
What are the pricing details for Cloudflare Containers?
Cloudflare Containers have a usage-based pricing model, charging for memory, CPU, and disk usage. For example, memory is billed at $0.0000025 per GiB-second with 25 GiB-hours included. Users only pay when the container is actively running, making it cost-effective for bursty traffic.
What are the benefits of using Containers over Workers?
Containers provide more power and flexibility compared to Workers, allowing for heavier workloads and complex applications. They are ideal for tasks requiring more resources, while Workers remain lightweight for simpler tasks. This dual approach enables developers to choose the right tool for their specific needs.

Key Statistics & Figures

Initial container start time
a few seconds
This quick start time is crucial for applications requiring immediate response to user requests.
Maximum instances per container
80
This limit allows for substantial scalability while managing resource allocation effectively.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Cloudflare Workers
Used to manage routing and logic for requests directed to Container instances.
Tools
Docker
Used for defining container images that can be deployed on Cloudflare.

Key Actionable Insights

1
Leverage Cloudflare Containers to simplify global application deployment.
By deploying to Region:Earth, developers can avoid the complexity of managing configurations across multiple regions, ensuring a seamless global experience for users.
2
Utilize the wrangler dev command for an efficient development workflow.
This command allows developers to build and test their container images locally, facilitating quick iterations and reducing deployment times.
3
Take advantage of built-in observability features for monitoring Container performance.
With metrics available in the Cloudflare dashboard, developers can track resource usage and status, enabling proactive management of their applications.

Common Pitfalls

1
Failing to properly configure the container settings in wrangler.jsonc can lead to deployment issues.
Ensure that the default port and image are correctly specified to avoid runtime errors and ensure proper routing of requests.
2
Overlooking the need for observability can result in undetected performance issues.
Utilizing the built-in metrics and logs is essential for maintaining application health and performance, especially in production environments.

Related Concepts

Cloudflare Workers
Container Orchestration
Serverless Architecture