Kafka-Style Streams on R2? Cloudflare K2 Enters Public Beta
Hi, Shii-chan here! Here's the announcement of Cloudflare K2, event streams running on top of R2!
Cloudflare BlogWhat was announced?
The Cloudflare Blog announced Cloudflare K2, a serverless event streaming service. It is built directly on R2 object storage for high-scale data movement and long-term retention. By decoupling producers and consumers at the edge, it gives you durable, ordered log streams without the operational overhead of traditional broker clusters.
It is in public beta now, and it requires a Workers Paid plan.
Why it matters
In traditional streaming, producers and consumers must align in scale and in time. K2 solves this by letting independent readers consume at their own pace without losing events.
What changes
- You get ordered, durable logs without running broker clusters
- Compute and storage are separated, so they scale independently
- Long-term retention stays cheap
Dive Deep
How it works
K2 is a partitioned, durable log on top of R2. Object storage has no append operation, so edge services accumulate writes in memory and write complete segment files to R2. Ordering uses R2's atomic operations, so no separate coordination service is needed.
Guarantees and performance
- Durability: built on R2's "11 9s" durability
- Ordering: events stay strictly ordered within a stream
- No data loss: events are never dropped once accepted
- Reading: supports both work-splitting subscriptions and pub/sub
- Produce latency: about 1 second at p99, because of batching and object storage write speeds
What it looks like
Creating a stream looks like this:
cf k2 streams create --name app_events --http-enabled
Sending from a Worker binding looks like this:
const result = await env.EVENTS.send([{
content: new TextEncoder().encode(JSON.stringify({event: "page_view"})),
headers: {"content-type": "application/json"}
}]);
Subscriptions split work among consumers, and messages are leased for 5 minutes. Consumers can ack, nack, or extend leases.
Public beta limits and pricing
- Storage: up to 10 GB per account
- Produce: up to 30 MB/s per stream
- Free during the beta. After the beta: $0.04/GB produced, $0.04/GB consumed, and $0.02/GB/month retained
How it differs from other services
- Queues: handles individual work items with retries and dead-letter logic. K2 is for batch data movement at scale
- Basin Pipelines: specialized in writing to object storage and Iceberg tables. K2 suits custom processing and varied destinations
Roadmap
Upcoming features include multi-GB/s write parallelism, message keys with key-based ordering, push-based Workers, a lower-latency Express tier, and Apache Kafka client compatibility.
Wrap-up
- K2 is a serverless event stream on R2, in public beta
- Durable and ordered, with about 1 second p99 produce latency
- Free during the beta with 10 GB and 30 MB/s limits, and usage-based pricing later
- Different use cases from Queues and Basin Pipelines
This is for anyone tired of running Kafka brokers, or who wants cheaper long-term log retention!