Moving to Cloudflare

3 months ago 5

Preface: I just want to say that I absolutely adore the Vercel team and love everything they have been working on so far. But Cloudflare is based (just see their recent blog catalog, and the main thing that sold me on Cloudflare was Quicksilver, but enough glaze 😅)

Also I’m not a frontend engineer by trade, so I’m not going into too much details about the benefits between these providers for specific frameworks. So I want you, the reader to treat this from a perspective of a consumer, who enjoy writing somewhat fruitful static files on his weekend. 🙂

I finally found some pockets of time over the last two weekends slowly migrating all of this site infrastructure to Cloudflare. I would want to say so far, the experience has been nothing but great.

Previously, this site were being run with a mixed between Vercel (functions) and Cloudflare (Domains and DNS), which in turn has caused me a lot of friction for prototyping/adding new features I want to build. This post will demonstrate what I enjoy about using both and what both providers can improve, and will explain the decision behind going with Cloudflare versus other alternatives.

”genealogy” of the sites

This website is entirely built with a customised version of QuartzQuartz (you can find more details here):

  • 812ac42: I first open-source this implementations, requested by a few friends
    • Hosted with GitHub Pages, DNS managed by gen.xyz
    • Vercel Functions for curius feed, arXiV popover, and code rendering
      • This is functional, but rather pretty slow, given that there are a few round-trip needed to be done between GitHub Pages and Vercel
  • ce7bcee: The first initial version of prototyping Andy Matuschak’s notes with Quartz
    • jackyzha0/quartz#128 requests for a view with default Quartz
    • Added Vercel Middleware to redirect DNS
      • Given that notes.aarnphm.xyzapex and aarnphm.xyzapex points to the same source, I end up having to setup build process on Vercel similar to GitHub Pages.
      • Which ends up having two copies of the exact same sites over two different cloud buckets!

        Retrospectively, I could have moved all over to Vercel at this point, but I was trying to skim through the free offering from both providers.

  • At some point along the way, I had exceed the limits for GitHub LFS Free tier.
    • I was tempted to just add more storages, but it is pretty expensive (ik $10 is 2 cups of coffee, but if you can do it for free, why not)
    • Found milkey-mouse/git-lfs-s3-proxy and milkey-mouse/git-lfs-client-worker contains setup for your own Git LFS with Cloudflare R2
      • Cloudflare is relatively generous with their quotas and storages for free tier
      • I did a quick comparison with Vercel Blob. However, the pricing seems to be a bit more on the expensive side.
      • For the tasks that I want to achieve (which is current hosting PDFs), Cloudflare is a better choice here
  • Moved all DNS, domain to Cloudflare, and migrated to Cloudflare Pages
    • I was also considering to use Vercel DNS, but given that I have already been on R2 at this point, it seems prudent to use Cloudflare for the sake of simplicity
      • Lee Rob from Vercel reached out for feedback, so I’m indeed very much bullish on Vercel on their care/dedications to their customers.
    • Their free tier encapsulates pretty much all features I would ever needed, for now.
    • The only reasons I haven’t yet migrated to Cloudflare fully is because wrangler 3 was rather hard to use with TypeScript, and Vercel supports for TypeScript is superior at this point.
  • 6aadff3: Migrated to Cloudflare Workers
    • Upgrading Quartz to the latest 4.5.x requires a major changes into how it handles incremental builds, so I found that this was a good time to switch/migrate fully to Cloudflare Workers.
      • They have now a lot better TS supports, with wrangler types and wrangler dev, which simplifies the setup a ton with Quartz.
      • Migrating from Pages and Workers are very refreshing, as their docs details all that you need to look out for.
        • I haven’t seen a lot of good documentations, other than Cloudflare, Amazon, and Vercel.

pros and “not-pros-yet”.

You can pretty much Google comparison all day long to see whether it is sensible to migrate your whole infrastructure between these two providers.

At the end of the day, the following are what I care about when building a functional website:

  • Performance: I want people who cares about optimizing for miliseconds
  • Security: reduce crawlers, fast, 100% uptime, so that I don’t have to worry about them.
  • Intuitive UX: follows zero-config philosophy (I think Ghostty is a prime example of this). I don’t have to configure a tons of stuff and can simply toggle items on the dashboard
  • Friendly developer tooling: I want to write code, so tooling must be good.
  • Pricing: free offering, otherwise pay-per-usage billing. Lenient on storage is a huge plus.
CriteriaCloudflareVercel
Performance🚧 1
Security🚧 2
Intuitive UX
Friendly developer tooling🚧 3
Pricing🚧

From this comparison, Cloudflare did seem to come out on top, for my use-case. However, I don’t think this would be a signal for you to move to Cloudflare completely.

Vercel is good for you if:

  • developer UX and building sites with supported frameworks. Next, Svelte, Solid are all amazing to work with when using vercel (from my experience on other projects)
  • seamless user experience with observability and metrics from their dashboard.
  • suite of products and resources for you to build your next 1M ARR business you’re willing to 😃

Cloudflare is good for you if:

  • If you care about security and don’t have to worry too much about the minor details
  • static sites
  • free plan

They both have AI-related products, but I’m not going to compare it here given that I don’t use them extensively.

Finally, I do have a lot of conviction in Cloudflare, through their open sourceand their leadership. However, it goes without saying that Vercel is still considered as a startup, comparing to Cloudflare, a publicly traded company. The mere sizes comparison between the two shows how far Vercel has come and essentially brings competition to these giants, and I can’t wait for one day, for Vercel to win.

Read Entire Article