f1-micro-traffic-test
Web Development

How Much Traffic Google Cloud f1-micro Instance can Handle

Since Google has been offering the improved version of their “Always Free” tier, hosting website on their cloud platform seems to be a compelling option. Especially for small websites or blogs with low traffic that stay under free tier quota could end up paying nothing at all. But with correct cache and CDN setup, you can also handle an incredible amount of traffic using just the free tier instance, f1-micro (this website for example) Let’s check it out in this post!

Google Always Free Tier

The only instance that eligible for Google Always free tier is f1-micro which has 0.2 vCPU and 0.6GB RAM. With this amount, you can only host blog or static content and forget about CPU/Database intensive website like forum or e-commerce.

Google is also generous enough to provide a burst capability that allow you to utilize the entire vCPU for a short period (same as having 1 vCPU) So you can still handle a handful of concurrent visitors if needed. The burst lasted around 30 second which you’ll see the CPU usage chart go above 100% like this.

f1-micro-burst

The Web Server

Many people usually go with LAMP stack (Linux + Apache + MySQL + PHP) for WordPress website. It’s understandable but since our resource is limited, you might want to look at alternative replacement that is more efficient for static website like Nginx or OpenLiteSpeed.

For this website, I tried OpenLiteSpeed which boast several times faster performance than Apache with less CPU/RAM usage. There is a nice stress test comparing between OpenLiteSpeed vs Nginx that might help your decision.

Cache and CDN Setup

Since we’re hosting a static content website, Cache and CDN setup could reduce our load greatly. Cloudflare and good WP Cache plugin (e.g. WP Rocket, WP Fastest Cache) In my case, I got 70% reduction of incoming requests (from 1.4 million to 412K requests) This means with Cloudflare, our f1-micro instance can handle around 3x more traffic!

cloudflare-request-cache

Increasing Memory using Swap

Remember that f1-micro only has 0.6GB RAM (581MB to be exact) So we’ll need to allocate a swap file, just in case we ran out of memory. You can do that easily with these command below.

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Now you’ll have 1GB swap file ready. Even you already have plenty RAM available, it’s still beneficial to have swap

The Result

Currently redstapler.co has around 137K pageviews/month (around 100K unique visitors)

analytics-redstapler

And below is the daily CPU and RAM usage chart

f1-micro-wordpress-cpu-stat

f1-micro-wordpress-ram-stat

You’ll see that’s only around 20% CPU utilization while RAM usage was stable at around 50% which means we can push even more traffic on this instance. (The highest spike was when I published the new post and got many concurrent visitors) So now the only cost for hosting website on Google Cloud is the network bandwidth usage (was greatly reduced by Cloudflare) which is around $1.5/month. That’s even cheaper than a lowest shared hosting plan!!!

As you can see, with the right WordPress cache plugin setup, using Cloudflare CDN to reduce load, turn on swap and using a good web server, a tiny f1-micro can easily handle 100K-200K unique visitors/month for static website without any issue. Personally, I believe we can even push it to 500K visitors/month. Anyway, I’ll update this post again later if our website has reached that state 🙂

Update: I made an article about cost breakdown of hosting website on Google Cloud. Just in case you might want to check it out!

Written By

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *