DEV Community

Juan Diego Isaza A.
Juan Diego Isaza A.

Posted on

Cloudflare R2 vs S3: Which Object Storage Wins?

If you’re running apps on a VPS and paying object-storage bills, cloudflare r2 vs s3 isn’t a theoretical debate—it’s the difference between predictable costs and surprise egress charges.

Cost model: egress is the whole game

Amazon S3 is the default choice because it’s everywhere, but the pricing model often hurts VPS-hosted workloads: storage is cheap-ish, requests add up, and egress can be brutal the moment your traffic grows.

Cloudflare R2’s main pitch is simple: zero egress fees (from R2 to the public internet). In practice, that changes architectural decisions:

  • Static assets + public downloads (images, firmware, media): R2 tends to be easier to budget.
  • Data leaving AWS (e.g., your VPS on hetzner reading S3): S3 egress can dominate costs.
  • High request volume: both charge for requests; read/write patterns still matter.

Opinionated take: if your workload is “serve lots of bytes to users,” egress is the primary line item, and R2’s model is hard to ignore.

Performance & latency from a VPS

For VPS_HOSTING, latency depends less on “S3 vs R2” and more on where your compute sits and how you cache.

  • S3: You choose a region (us-east-1, eu-central-1, etc.). If your VPS is in the same region (say AWS EC2), you can get great latency and private routing options.
  • R2: Backed by Cloudflare’s global network; you don’t pick “a single region” the same way. Latency can be very good for globally distributed users—especially when paired with Cloudflare’s edge.

If you’re hosting on digitalocean or hetzner, you’re usually not co-located with AWS’s internal network. That means S3 access is standard public-internet traffic unless you build something more complex. R2’s “close to users” model often pairs nicely with a VPS that’s simply “close to your database” while the edge handles asset delivery.

Practical rule:

  • VPS + global audience + lots of downloads → R2 plus edge caching is typically the fastest-to-implement win.
  • VPS inside AWS or deep AWS integrations → S3 can be smoother operationally.

Features & ecosystem: S3 is the platform, R2 is the product

S3’s biggest advantage isn’t raw storage—it’s the ecosystem:

  • Mature IAM policies, org controls, compliance tooling
  • Event integrations (Lambda, EventBridge)
  • Lifecycle policies, replication options, Object Lock, analytics
  • Every third-party tool supports S3-first

R2 is intentionally compatible with the S3 API for basic operations, which gets you most of the day-to-day functionality: buckets, objects, signed URLs, multipart uploads. But some “AWS-native” features don’t map 1:1.

Opinionated take: if you rely on AWS’s storage-adjacent services (serverless triggers, cross-account governance, deep audit trails), S3 is still the safest choice. If you just need object storage that doesn’t punish bandwidth, R2 is usually enough.

Actionable example: migrate a bucket with rclone

If you’re on a VPS and want to test R2 without rewriting your app, do a straight copy using rclone.

1) Install rclone on your VPS.
2) Configure two remotes: one for S3, one for R2 (S3-compatible).
3) Copy and verify.

# Copy an S3 bucket prefix to an R2 bucket
rclone copy \
  s3remote:my-s3-bucket/uploads \
  r2remote:my-r2-bucket/uploads \
  --progress --transfers 16 --checkers 32

# Spot-check differences (metadata handling varies by provider)
rclone check s3remote:my-s3-bucket/uploads r2remote:my-r2-bucket/uploads
Enter fullscreen mode Exit fullscreen mode

Notes that matter in real life:

  • Test signed URLs and cache headers after migration.
  • Verify your application doesn’t rely on S3-only features (like specific event notifications).
  • If you serve public content, decide whether you want a CDN in front. With R2, the Cloudflare edge story is compelling, but your app still needs sane cache-control.

Recommendation for VPS hosting (and when to pick each)

Here’s the blunt version.

Choose Cloudflare R2 if:

  • Your VPS provider is outside AWS (common with hetzner/digitalocean) and your app serves lots of public bytes.
  • You’re tired of optimizing around egress (thumbnails, downloads, backups) instead of shipping features.
  • You want simple S3-compatible storage and can live without the deepest AWS-native integrations.

Choose Amazon S3 if:

  • You’re already heavily invested in AWS workflows, compliance, and event-driven pipelines.
  • You need advanced features like Object Lock or mature replication/analytics controls.
  • Your compute is in AWS and you can keep traffic “inside the same cloud” most of the time.

Soft closing thought for VPS builders: pairing a cost-efficient VPS (for example, on digitalocean or hetzner) with Cloudflare’s network can be a pragmatic way to scale delivery without rebuilding your whole stack—especially when object storage egress starts showing up as a bigger number than your actual servers.


Some links in this article are affiliate links. We may earn a commission at no extra cost to you if you make a purchase through them.

Top comments (0)