Cloudflare R2 vs S3 for Event-Driven Data Pipelines
In this article
- Background: What Event-Driven Data Pipelines Need from Object Storage
- How S3 Event Notifications Work
- How Cloudflare R2 Event Notifications Work
- Cost Comparison: Egress Fees vs. Request Pricing
- Performance and Consistency
- Integration and Ecosystem
- Common Problems and Misconceptions
- How to Choose: Decision Factors
- Frequently Asked Questions
Cloudflare R2 and AWS S3 both store objects, but for event-driven data pipelines the practical difference comes down to egress fees, event delivery mechanics, and ecosystem lock-in. R2 charges zero egress fees and offers native Pub/Sub integration, while S3 provides mature event notifications and the broadest tooling ecosystem. This article compares both services specifically for event-driven workloads, covering architecture, costs, and real-world trade-offs.
Background: What Event-Driven Data Pipelines Need from Object Storage
An event-driven data pipeline reacts to changes in storage—a new file lands, an object is updated, or a delete occurs—and triggers downstream processing (e.g., transforming data, loading into a warehouse, or invoking serverless functions). The storage layer must reliably emit events with low latency, support high throughput, and integrate with compute services. Both R2 and S3 provide these basics, but their event models and surrounding services differ significantly.
How S3 Event Notifications Work
S3 uses event notifications that publish messages to Amazon EventBridge, SNS, or SQS when object-level operations occur. You configure a notification on a bucket prefix or suffix, and S3 delivers events like s3:ObjectCreated:* or s3:ObjectRemoved:*. These events typically arrive within seconds, but delivery is at-least-once—your consumer must handle duplicates. S3 also supports event-driven workflows via Lambda, where a function is invoked directly on object creation, and S3 Batch Operations for large-scale processing.
Key S3 strengths:
- Mature event routing to multiple targets (Lambda, SQS, SNS, EventBridge) with filtering by prefix/suffix.
- Strong consistency since 2020—all reads and writes are strongly consistent, so events reflect the latest state.
- Vast ecosystem—most data tools (Spark, Kafka connectors, Airflow) have native S3 integrations.
How Cloudflare R2 Event Notifications Work
R2 offers event notifications that publish to Cloudflare Queues or Workers. You create a queue, attach it to a bucket, and configure rules for object creation, deletion, or metadata changes. Events are delivered to a Worker consumer, which can process them in batches. R2 also integrates with Pub/Sub for real-time messaging, and with Durable Objects for stateful processing. However, R2 does not have a direct integration with external message brokers like Kafka or SQS—you must bridge via Workers or HTTP.
R2’s event model is simpler but more Cloudflare-centric. It lacks the fine-grained filtering of S3 (e.g., you cannot filter by object size or tags), and event delivery is also at-least-once. For pipelines that already use Cloudflare Workers, this tight coupling is an advantage; for those relying on AWS services, it’s a barrier.
Cost Comparison: Egress Fees vs. Request Pricing
The most cited difference is egress. S3 charges per GB for data transferred out to the internet (typically $0.09/GB for the first 10 TB/month), which can dominate costs for pipelines that read large datasets frequently. R2 charges zero egress fees—you pay only for storage and Class A (write) and Class B (read) operations. For event-driven pipelines that repeatedly read data (e.g., retries, reprocessing), R2 can be significantly cheaper.
However, S3’s pricing includes a free tier (5 GB storage, 20,000 GETs, 2,000 PUTs per month) and offers lifecycle transitions to cheaper storage classes (e.g., S3 Glacier for archival). R2 has a generous free tier (10 GB storage, 1 million Class A operations, 10 million Class B) and no lifecycle tiers—all data is stored in one class. If your pipeline needs archival storage, S3’s tiering may lower costs despite egress.
Also consider request costs: R2 charges $4.50 per million Class A operations and $0.36 per million Class B, while S3 charges $0.005 per 1,000 PUTs and $0.0004 per 1,000 GETs. For high-volume pipelines, R2’s operation costs are higher, but egress savings often outweigh them.
Performance and Consistency
Both services offer low-latency access, but there are nuances. S3 has strong consistency for all operations—a read after a write returns the latest version. R2 also provides strong consistency, but its performance can vary based on the location of the compute relative to the bucket. R2 uses a global network, so Workers in the same region as the bucket get lower latency; cross-region access may add overhead. S3’s regional design means you choose a region for your bucket, and compute in the same region gets the lowest latency.
For event delivery, S3’s notifications are typically faster (sub-second to a few seconds) because they are integrated with AWS’s internal event bus. R2’s notifications go through Queues, which may introduce a small delay (often under a second) but support batching for efficiency. In practice, both are suitable for near-real-time pipelines.
Integration and Ecosystem
S3 is the de facto standard for data engineering. Tools like Apache Spark, Flink, Kafka Connect, and dbt have first-class S3 connectors. AWS services (Glue, EMR, Athena, Redshift Spectrum) are tightly integrated. If your pipeline uses these, S3 is the path of least resistance. R2, being S3-compatible, works with many S3 SDKs and tools, but some advanced features (e.g., S3 Select, object locking) are not implemented. For event-driven processing, R2’s native integration with Workers and Queues is powerful, but you lose direct access to AWS’s serverless ecosystem.
Common Problems and Misconceptions
A common misconception is that R2 is a drop-in replacement for S3 in all pipelines. While the S3 API compatibility is high, not all features are present. For example, R2 does not support S3 Object Lock (WORM), which some regulated pipelines require. Also, R2’s event notifications do not support filtering by object metadata or tags, which can force you to process more events than needed.
Another issue is eventual consistency for event delivery: both services guarantee at-least-once delivery, so your pipeline must be idempotent. If you use S3 with SQS, you get a built-in dead-letter queue; with R2, you must implement retry logic in your Worker. Finally, cross-cloud pipelines (e.g., using R2 with AWS Lambda) require a bridge, adding latency and complexity.
How to Choose: Decision Factors
Consider these factors:
- Egress volume: If you read large amounts of data frequently, R2’s zero egress saves money.
- Compute environment: If your pipeline runs on AWS (Lambda, ECS, Glue), S3 is more natural; if you use Cloudflare Workers or want to avoid cloud lock-in, R2 is simpler.
- Event filtering needs: S3’s prefix/suffix and object-size filters are more granular; R2 only supports prefix/suffix.
- Ecosystem dependencies: If your pipeline uses S3-specific features (Select, Object Lock, Batch Operations), S3 is required.
- Retry and dead-letter handling: S3’s integration with SQS provides built-in DLQs; R2 requires custom Worker logic.
For a new pipeline with no AWS legacy, R2 is a strong candidate due to cost. For existing AWS pipelines, S3 is usually the safer choice.
Frequently Asked Questions
Can I use R2 with AWS Lambda? Yes, you can use the S3-compatible API to read/write R2 from Lambda, but you cannot use S3 event notifications to trigger Lambda directly. You would need to use R2’s event notifications to a Worker, then call Lambda via HTTP, or poll the bucket from Lambda.
Does R2 support S3 event notifications to SQS? No. R2’s event notifications only go to Cloudflare Queues or Workers. You can bridge to SQS by having a Worker forward messages, but that adds a hop and potential latency.
Which has lower latency for event delivery? S3 notifications typically arrive in under a second when using EventBridge, while R2’s Queues may have a similar delay but can batch events, which might increase perceived latency if you wait for a batch. In practice, both are suitable for real-time pipelines.
Is R2 truly S3-compatible? R2 implements the S3 API for core operations (PUT, GET, DELETE, multipart upload), but not all features (e.g., S3 Select, Object Lock, bucket policies). Most SDKs work, but you should test your specific use case.
Can I migrate an existing S3 pipeline to R2? Yes, but you’ll need to update your event consumers to use Workers/Queues instead of Lambda/SQS, and you may lose some filtering capabilities. The data transfer itself is straightforward using the S3 API.
Which is cheaper for a high-volume event pipeline? If you egress more than a few TB per month, R2 is likely cheaper due to zero egress. However, if you use S3’s infrequent access or Glacier tiers, and your pipeline reads infrequently, S3 might be cheaper overall.