Introduction to Cloudflare R2
Cloudflare R2 is an S3-compatible object storage service that provides zero egress fees. This fundamentally changes the paradigm of cloud storage, allowing you to fetch data as often as you want without being penalized for popularity, making it an ideal choice for content delivery, data lakes, and heavy-read workloads.
The Egress Fee Problem
Traditional object storage providers (like AWS S3 or Google Cloud Storage) charge two types of fees:
- Storage costs (per GB stored)
- Egress costs (per GB transferred out of their network)
Egress fees act as a "data tax" and are notoriously high and unpredictable. If you host a popular video, the egress costs can easily be 10x or 100x the raw storage costs. This creates a vendor lock-in effect, as moving terabytes of data out of AWS incurs massive fees.
How R2 Architecture Solves This
R2 operates natively on Cloudflare's global edge network (over 300 cities worldwide).
graph TD
User([User]) --> |Request| Edge[Cloudflare Edge Node]
Edge --> |Cache Miss| R2[(R2 Storage Bucket)]
R2 --> |Serve Data| Edge
Edge --> |Zero Egress| User
style User fill:#f9f,stroke:#333,stroke-width:2px
style Edge fill:#bbf,stroke:#333,stroke-width:2px
style R2 fill:#f96,stroke:#333,stroke-width:2px
When a user requests an object:
- Zero Egress: You pay
$0for bandwidth out of R2. Cloudflare controls the entire network from the storage disk to the edge delivery, eliminating transit costs. - Predictable Billing: You only pay for raw storage capacity and Class A/B operations (mutations and reads).
Cost Modeling Comparison
Consider a scenario where you store 1 TB of video assets, but deliver 50 TB of video to users per month.
| Provider | Storage (1 TB) | Egress (50 TB) | Operations | Total Monthly Cost |
|---|---|---|---|---|
| AWS S3 (Standard) | ~$23.00 | ~$4,500.00 | ~$5.00 | ~$4,528.00 |
| Google Cloud Storage | ~$20.00 | ~$4,000.00 | ~$5.00 | ~$4,025.00 |
| Cloudflare R2 | $15.00 | $0.00 | ~$5.00 | ~$20.00 |
[!TIP] Class A vs Class B Operations:
- Class A (Mutating): Uploads (
PUT), copying, listing objects. Billed at $4.50 per million requests.- Class B (Reading): Downloading (
GET), metadata reads. Billed at $0.36 per million requests.- Deletes (
DELETE) are always free.
Data Residency and Jurisdictional Restrictions
For enterprise compliance (e.g., GDPR, HIPAA), data localization is critical. While R2 is inherently global, you can enforce Jurisdictional Restrictions when creating a bucket to ensure data never leaves a specific region at rest.
Supported jurisdictions currently include:
eu(European Union)fedramp(US FedRAMP boundary)
Note: Accessing an eu bucket from the US still incurs zero egress, but latency will be slightly higher as the request travels to the EU storage node.
S3 Compatibility Matrix
R2 is designed to be S3-compatible, meaning existing S3 tooling (aws-cli, SDKs, Terraform, Cyberduck) works out of the box.
However, it is not a 1:1 clone. Some advanced AWS-specific features are currently unsupported or handled differently:
| Feature | AWS S3 | Cloudflare R2 | Notes |
|---|---|---|---|
| Standard Upload/Download | ✅ Yes | ✅ Yes | Fully compatible |
| Multipart Uploads | ✅ Yes | ✅ Yes | Supported up to 5GB parts |
| Presigned URLs | ✅ Yes | ✅ Yes | Perfect for direct browser uploads |
| Bucket Versioning | ✅ Yes | 🚧 Planned | Not yet natively supported in R2 |
| Object Lock (WORM) | ✅ Yes | ❌ No | Cannot enforce write-once-read-many |
| Fine-Grained IAM | ✅ Yes | ⚠️ Partial | R2 uses broader token scopes vs granular IAM |
Strategic Use Cases
R2 shines in architectures where egress dominates the cost profile:
- Global CDN Origins: Serving heavy assets (video, audio, high-res images) directly to browsers.
- Build Artifacts & CI/CD: Distributing large Docker images or binaries across globally distributed teams.
- Disaster Recovery: Storing massive database backups without fearing the cost of restoring them later.
- Data Lakes: Aggregating log data globally before processing it via Cloudflare Workers.
[!WARNING] Do not use R2 as a high-frequency, sub-millisecond database. If you need to read/write thousands of tiny JSON objects per second, use Cloudflare KV or Durable Objects. R2 is optimized for large objects and standard S3 latency.