How I host my Server-Side-Rendered F# site on Google Cloud for less than $1 per month

Date: 2024-01-09 | create | tech | business | fsharp | google-cloud | cloud-run |

I recently migrated my sites from SvelteKit to F# and did a review of how much money my projects made vs how much they cost.

In this post I wanted to dive into how much it costs me to run this site on Google Cloud.

Site Overview

My site is mostly static content using server-side rendered HTML built with F# and Giraffe.ViewEngine. This means it doesn't really do that much work and doesn't need that much infrastructure - really just a server it can run on and will accept connections.

For an idea of scale, my sites get approximately 50k views a year which comes out to about 0.002 requests / second which is quite small in software terms. Yes this traffic isn't continuous so has regular spikes / dips but we can assume it's still pretty small.

How I host my site

I run my site on Google Cloud Run which is a serverless managed container service on GCP. It works by spinning up a container image of my site when a request comes in. That container is kept running to serve subsequent requests and then goes to sleep after a few minutes if no more requests come in.

I like this because:

  • Easy to Use - Very simple to spin up a container and don't have to deal with server setup / configuration (think serverless).
  • Flexible - Because it runs containers natively you can run anything you can run in a container (which is basically anything). This makes this approach work for basically any usecase (I've previously run everything from C# to SvelteKit to static Hugo sites this way).
  • Scalable - My sites don't get much traffic but it's nice to know I could scale big if I wanted. GCP is a fully equipped cloud so planet scale is an option.
  • Cheap - Cloud Run is scale-to-zero so I only really pay when people are using my site. Because my usage is low, I mostly fall under the free tier and pay very little.

I find this gives me a nice balance of ease of use, high scalability, and low cost - a Simple Scalable System if you will.

How much it costs

Google Cloud Hosting Costs (with discounts)

Hosting my site in 2023 cost me about $6.70 ($0.56 per month).

  • Cloud Storage - $4 (60%) - This is static file hosting for things like images / videos I use in post embeds
  • Cloud Run - $2.63 (39%) - This is for actually running my code and serving my site
  • Artifact Registry - $0.05 (1%) - This is for building my containers and storing them for use in Cloud Run

Note though that this is the price that I actually paid but includes discounts like credits / free tier. I find that most clouds use this to try and make it seem cheaper than it is so I wanted to also share how much it would've cost if those discounts weren't there to better model what this would cost at scale / for average builder.

Google Cloud Hosting Costs (without discounts)

Without discounts, my site costs would've been $10.36 for the year ($0.87 per month).

  • Cloud Storage - $6.32 (61%)
  • Cloud Run - $4.00 (39%)
  • Artifact Registry - $0.05 (0%)

Not bad but still a good 50% more expensive.

Next

Overall I've had a really good experience with Google Cloud Run. I've been using them for years to host my own side projects and would recommend them for others as well. I'm not totally sure how it would work at scale (with a site / service that gets a lot of traffic) as I've never done that myself and I can see how costs could go up dramatically if it never scaled to zero but for my purposes it works well and costs little for the value I get out of it.

I'll probably be exploring some other hosting options this year as I play around with building more projects so stay tuned if you're interested in that.

If you liked this video you might also like:

Want more like this?

The best / easiest way to support my work is by subscribing for future updates and sharing with your network.