Skip to main content

sometechblog.com

Don’t Overpay for Bandwidth

After adding an embedded video to the landing page of my app I noticed bandwidth usage rose dramatically. The embedded video is auto-loaded for best experience and provides a sleeker experience than a YouTube embed. In a week the landing page videos both the optimized .webm (5.1MB) and .mp4 (20.4MB) consumed close to 25GB of bandwidth.

This would push me out of the free tier and into a steeply priced PRO subscription. A PRO subscription cost $20/mo ($240/y) and includes 1TB of bandwidth, but Vercel charge $40 per additional 100GB. Nothing crazy but costs creep up on you if you are vigilant. But thankfully an alternative exists.

Cloudflare static file hosting, R2, offers 10GB of free storage, zero egress fees, and it is easy. I set it up while drinking my morning tea, literally. The steps are:

  • click on the R2 link in the Cloudflare dashboard and add a bucket
  • upload files to be shared (max 300MB)
  • click the settings tab and add custom domain that you want files shared from

That is it. Now you can embed files using the custom domain without paying expensive egress fees. You can see the embedded video here and this is how the R2 bucket UI looks:

Cloudflare R2 the bucket admin UI

Edit:

  • use custom (sub)domain instead of rate limited r2.dev for production.