Source: Cloudflare

What Is Cloudflare, and How Can It Save You Server Costs?

Cloudflare, a cloud provider, can help you cut your costs significantly while increasing performance

Everything revolves around the cloud in today's world, allowing applications to do things that could not be done on the client. However, doing this incurs many costs, and if done incorrectly, can significantly slow down your applications. A lot of these problems can be solved by changing cloud providers or services. While most companies use things such as AWS (Amazon Web Services), or GCP (Google Cloud Platform), a newer competitor, Cloudflare, has managed to make many technological advantages in cost and performance. In this article, we will look at various Cloudflare services and how they compare to different cloud providers.

Hosting Services

Cloudflare CDN: Edge CDN

One of Cloudflare’s most popular services is its CDN. It allows you to put an edge CDN in front of your web server, decreasing latency for your users and allowing some optimizations that might not be enabled on your origin server (although most can be with some work). The biggest advantage of using the Cloudflare CDN over something like Amazon CloudFront is its pricing. Cloudflare’s CDN, by default, is free. Even though it is free, it can still scale to terabytes, without you having to move to a paid plan (although more features are offered in the paid plan). Along with its price, Cloudflare CDN is fast, with a massive edge network and the fastest Authoritative DNS.

Pros

  • Cheap
  • Fast

Cons

  • Less customizable compared to services like Fastly
Cloudflare Workers logo

Cloudflare Workers: V8 Serverless Functions

Cloudflare Workers is Cloudflare’s edge serverless service, which uses JavaScript and Web Assembly. However, it is not like most serverless providers. Instead of using Node.js for the runtime, it uses V8, which can be optimized to make multiple workers be able to be run in the same process securely, using isolates. This makes it so cold starts are reduced and costs are decreased. So basically, Cloudflare Workers are Service Workers, in the cloud.

Cloudflare Workers Hello World example

This comes at the cost of not having many Node APIs, but by using bundlers and other web build tools, you can use some packages on NPM without changing anything. Currently, the developer experience of Cloudflare Workers is not great, with some Node incompatibilities and a 1-megabyte script size limit. However, in some cases, the pricing, which is ¢50 per million requests with 100,000 requests free, and the performance, with 0ms cold starts, outweighs the developer experience. Cloudflare Workers can also do Server-Side Rendering, and frameworks like SvelteKit support it with a plugin.

Pros

  • No cold starts
  • Super cheap
  • Runs on edge

Cons

  • Requires bundler to use NPM packages
  • Cannot use some Node APIs
  • 1-megabyte script size limit
Cloudflare Pages logo

Cloudflare Pages: Simple Static Site Hosting

Cloudflare Pages is Cloudflare’s JAMStack (JavaScript, APIs, Markup) hosting platform. It has simple GitHub CI and can easily be integrated with Cloudflare Workers. It allows you to easily integrate your GitHub repo into Cloudflare and deploy it for free. Unlike some one-click deploy providers like Vercel and GitHub Pages, Cloudflare does not have a free plan bandwidth limit. Plus, it has optimizations like Gzip, Brotli, and Http/3 automatically applied if the user supports it. It does not have the same easy serverless functions integration as Vercel, but serverless functions can still be implemented with some work using Cloudflare Workers. Additionally, because of Cloudflare’s wide network, it is fast. If you are using Next.js or another framework that is integrated into a provider or does not have support for Cloudflare Server-Side Rendering, then that hosting service will be easier. Otherwise, Cloudflare Pages might work well for you.

Pros

  • Low latency
  • Completely free bandwidth
  • GitHub integration

Cons

  • Needs to use Workers for Server-Side Rendering
  • Some configuration is needed to integrate Workers and API routes.

Conclusion

Cloudflare can be a very fast and cost-effective way of running a basic server. However, it is not for everyone. I encourage you to look at Cloudflare along with other server hosting services and draw your own conclusions. Thank you for reading, and I hope you have learned something new from this.

Note: I am not affiliated with Cloudflare

A JavaScript and Web dev enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store