MpegFlow with Cloudflare R2: zero-egress video storage
How MpegFlow integrates with Cloudflare R2 — the S3-compatible API, zero-egress economics for CDN delivery, and the multi-cloud benefits over AWS S3 lock-in.
Cloudflare R2 is the S3-compatible object store with zero egress fees — a meaningful cost lever for video workloads where egress to CDN typically dominates the storage bill. R2 pairs naturally with Cloudflare's CDN (no egress between R2 and Cloudflare), and works as a multi-cloud play to reduce AWS lock-in. MpegFlow integrates with R2 via the standard S3 protocol; the strict-broker security pattern is identical.
How the integration works
R2 implements the S3 API, so MpegFlow's coordinator uses the same presigned URL generation logic as AWS S3 — pointed at R2 endpoints (e.g., https://<account-id>.r2.cloudflarestorage.com). Workers download mezzanine and upload outputs via R2 presigned URLs; they hold zero credentials. The integration is byte-for-byte identical to S3 from the worker's perspective.
Common patterns
CDN-resident workflows for zero egress
Encode → R2 → Cloudflare CDN delivery → end users. No egress from R2 to Cloudflare's CDN, no egress from Cloudflare to end users (covered by your bandwidth plan). The whole pipeline post-encode is essentially zero variable cost on bandwidth.
Multi-cloud with R2 + S3
For multi-cloud architectures, pair R2 (zero-egress CDN delivery) with S3 (mezzanine storage in AWS for proximity to existing pipelines). Replication via the Cloudflare Workers SuperSlurper or rclone keeps the two in sync.
Sovereign-cloud requirements
For workloads where AWS data-residency is a problem (specific EU regulators, sovereign-cloud requirements), R2's data-residency model (Jurisdiction option) can satisfy compliance where S3 cannot. Talk to legal before committing.
Cost calibration for high-egress workflows
Egress is where R2 pays back the migration cost. A workflow encoding 1M minutes/month and serving 10M hours/month of video has ~5 PB of egress. R2 → Cloudflare CDN is $0/GB; S3 → CloudFront is ~$0.085/GB after free tier. The arithmetic for high-egress is dramatic.
Pitfalls
- R2 is S3-compatible but not byte-for-byte: certain S3 features (Object Lock, requester-pays) don't exist in R2. Test your specific workflow before assuming full compatibility.
- R2 egress to non-Cloudflare destinations is metered: only egress to Cloudflare's edge is free. Don't assume zero egress for cross-cloud workflows.
- R2 region selection is automatic (no explicit region); for sovereign-cloud requirements use the Jurisdiction option (EU, FedRAMP) instead.
- R2 throughput limits are different from S3: per-bucket request rates and parallel-upload limits don't map exactly. Profile for your workload.
- Cloudflare account billing for R2 is separate from your AWS account billing — operationally meaningful for finance + procurement teams.
At production scale
R2 is well-suited for high-egress video workflows because the egress is the dominant cost in production. Storage pricing is comparable to S3 (~$0.015/GB/month vs S3's ~$0.023/GB/month). Request pricing is also competitive ($0.36/M Class A operations, $0.36/M Class B operations after free tier — typically lower than S3 for video workloads). The migration cost from S3 to R2 is non-trivial for petabyte-scale archives, but the egress savings typically pay back within 6-12 months for high-traffic services.
- cloudflare
- r2
- storage
- integration
- multi-cloud