DEV Community

Juan Diego Isaza A.
Juan Diego Isaza A.

Posted on

Cloudflare R2 vs S3 for VPS Hosting: What Wins?

If you’re running apps on a VPS, cloudflare r2 vs s3 isn’t a theoretical debate—it’s a monthly line item and a performance bottleneck waiting to happen. Object storage decisions show up as surprise egress bills, slow uploads, or painful migrations when your “simple” side project turns into real traffic.

What actually matters for VPS workloads

Most comparisons obsess over raw durability numbers and ignore the messy reality of VPS hosting: you’re usually serving assets to users, shipping backups, or storing user uploads—often from a server at digitalocean, hetzner, or similar.

For VPS-centric setups, prioritize:

  • Egress cost predictability: VPS bandwidth is already metered; pairing it with expensive object egress can double-punish you.
  • Latency to your compute: If your VPS pulls many small objects (thumbnails, JSON blobs), latency matters more than “infinite scale.”
  • S3 API compatibility: The less you change in code, the easier it is to switch vendors or run hybrid.
  • Operational friction: IAM complexity, credentials, and per-bucket policies can be heavier than your app deserves.

Opinionated take: for most VPS projects, the winner is the storage that keeps egress cheap and the API familiar.

Pricing reality: egress is the boss fight

Amazon S3’s storage pricing is competitive, but the real bill-killer is data transfer out. If you serve media directly from S3 to end users, your cost curve can spike fast.

Cloudflare R2 positions itself around the obvious pain: no egress fees (within Cloudflare’s ecosystem assumptions). That changes how you architect things:

  • With S3, you often add a CDN (CloudFront or another) primarily to reduce egress and improve caching.
  • With R2, you can lean into Cloudflare’s edge network and avoid the “why is bandwidth the most expensive part?” moment.

Caveat (because marketing always has caveats): “no egress” doesn’t mean “no costs.” You still pay for storage and operations, and you may pay for requests depending on plan/usage. But in practice, the egress line item is what breaks budgets for image/video-heavy VPS apps.

If you’re hosting your app on hetzner (cheap outbound) and pulling objects from S3 (expensive outbound), you’ve built a cost sandwich where the premium ingredient is the one you use most.

Compatibility and features: S3 is the default, R2 is the pragmatic clone

S3 remains the industry default for a reason: broad feature depth and ecosystem gravity.

S3 advantages that show up in real projects:

  • Mature IAM and tooling (annoying, but powerful)
  • Rich storage classes (lifecycle transitions can save real money)
  • Ubiquitous integrations (backup tools, data platforms, SaaS vendors)

R2’s core advantage: it’s S3-compatible enough that most apps don’t care, and it removes egress pain.

Where you might feel differences:

  • Edge-native workflows: R2 pairs naturally with Cloudflare’s platform (Workers, caching, routing). If you’re already using cloudflare for DNS/CDN/WAF, it’s a simpler mental model.
  • Advanced S3 features: If you rely on niche S3 capabilities or deep AWS integration, S3 still wins.

Opinionated rule: if your app’s “storage requirements” fit in a README section, R2 is likely enough. If they require an architecture diagram and compliance review, S3 is safer.

Actionable setup: point a VPS app at R2 using the S3 API

Most VPS apps only need an S3-compatible endpoint. Here’s a practical example using AWS CLI to talk to R2 (works similarly from any server, including digitalocean droplets).

# 1) Configure credentials (use R2 access/secret keys)
aws configure set aws_access_key_id "$R2_ACCESS_KEY_ID"
aws configure set aws_secret_access_key "$R2_SECRET_ACCESS_KEY"
aws configure set default.region auto

# 2) Use the R2 S3-compatible endpoint
export R2_ENDPOINT="https://<accountid>.r2.cloudflarestorage.com"

# 3) Create a bucket and upload an object
aws --endpoint-url "$R2_ENDPOINT" s3 mb s3://my-vps-uploads
aws --endpoint-url "$R2_ENDPOINT" s3 cp ./avatar.png s3://my-vps-uploads/avatar.png

# 4) List objects
aws --endpoint-url "$R2_ENDPOINT" s3 ls s3://my-vps-uploads/
Enter fullscreen mode Exit fullscreen mode

This is the migration “cheat code”: if your application already supports S3 (most do), swapping endpoints and credentials can be 80% of the work.

So which should you pick for VPS hosting?

Here’s the blunt guidance I give people building on VPS providers like hetzner or digitalocean:

  • Choose Cloudflare R2 if you:

    • serve lots of public assets (images, downloads, media)
    • care about egress surprises
    • already use Cloudflare for CDN/DNS/WAF and want fewer moving parts
  • Choose Amazon S3 if you:

    • need deep AWS-native features or compliance patterns
    • run workloads already inside AWS (keeping traffic in-region can reduce transfer costs)
    • depend on mature lifecycle tiers and third-party integrations

Soft recommendation: if you’re price-sensitive (most VPS builders are) and your object store is primarily a “dumb blob bucket,” starting with R2 is a reasonable default. If you outgrow it, the S3-compatible surface area makes switching less traumatic than a proprietary API.


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)