Cloudflare K2 is a serverless event streaming primitive launched on the Developer Platform to address a fundamental challenge in event-driven architectures: maintaining alignment between data producers and consumers. According to Cloudflare's announcement, traditional RPC architectures often face issues where producers send data faster than consumers can process it, or where consumer downtime leads to dropped events. K2 solves this by inserting a durable buffering service that absorbs writes while allowing independent readers to consume data at their own pace, effectively decoupling the two sides of the pipeline. The company initially developed K2 to serve as the ingestion layer for Basin Pipelines, which requires durable storage to prevent data loss during consumer downtime.

Under the hood, K2 implements a partitioned, durable log using Cloudflare's R2 object storage as its foundation. Rather than relying on traditional append-based logging, K2 accumulates writes in-memory on edge services before writing complete segment files to R2. The system leverages R2's atomic operations to achieve strictly incrementing offsets and maintain ordering without requiring a separate coordination service. This approach separates compute and storage layers, allowing independent scaling and enabling the storage of vast historical data volumes at low cost, benefiting from R2's 11 nines of durability. While K2's design offers significant advantages in scalability and durability, it comes with a trade-off in produce latency due to the need to accumulate writes before committing to object storage. Cloudflare notes this adds approximately one second of latency at the 99th percentile in the initial release.

Diagram of durable event streaming with Durable Objects and R2
Illustration of a durable event streaming system using Cloudflare Durable Objects and R2, a related technology to K2's event streaming approach.github.com

While the article describes K2 as a serverless event streaming service built directly on R2 storage, this image shows a similar concept using Durable Objects and R2, helping to visualize the durable event streaming paradigm discussed in the article.

The service is positioned between Cloudflare's existing asynchronous primitives: Queues for individual work item tracking with complex per-item logic (like retries, delays, and dead-letter queues), and Basin Pipelines for ingestion services focused on writing events to object storage or Iceberg tables. K2 is optimized for high-scale data movement, long-term retention, and fan-out consumption patterns, where messages are produced and consumed as batches enabling efficient processing at the expense of message-level retries. Users can create a stream via the cf CLI, Wrangler, the dashboard, or API, then produce events via HTTP API or Worker binding and create subscriptions for consumer applications to read from the stream.

K2 is available today in public beta for accounts with Workers Paid subscriptions, with limits of 10GB of storage used and 30 MB/s produce per stream. Usage during the beta period is free, and Cloudflare anticipates eventual pricing of $0.04 per GB for data produced, $0.04 per GB for data consumed, and $0.02 per GB per month for data retained. The roadmap includes higher write parallelism, message keys and key-based ordering guarantees, push-based worker consumers, an express tier with lower latency, and drop-in support for Apache Kafka clients.