Manage your Cloud Infrastructure Spend

Cost Engineering Example - Static Hosting

For any service you wish to build there are dozens of ways to design it. Each design will have its own strengths, limitations, and cost considerations.

In this article we will compare cost of three designs for a simple static file hosting service. We will illustrate how significantly the technical design affects the solution’s cloud platform cost.


The service we will design is the web hosting of a simple static file. Take this image of my grape vines for instance:

Image Example 1MB - Grapes

This image is 1MB. When I took it with my phone it was 3MB, but I scaled it down to 1MB for this example. Once loaded to social media, it gets scaled down to 100kb. But we’re working with a 1MB example.

This is a representative example. 1MB could represent a lot of things. It could be the size of an entire blog site, a modest single-page application (SPA), or a dozen typical-quality photos. We’re using this image for illustrative purposes only.

We will seek to host this file as economically as possible and make it available on the internet to anonymous users. This is generally referred to as static content hosting.

We want to minimize monthly costs, especially if no one is downloading the file. We also want to handle potential for ‘going viral’ and unexpected traffic if it becomes popular.

To simplify the analysis, we will look at how many requests we can serve with a monthly budget of $100.

Base vs. Usage Costs

In our comparison we will distinguish between Base cost and Usage cost of each design.

Base costs incur even if there is no usage activity for the service. E.g., no one downloads our file.

Usage costs are only incurred when a user accesses the service. If no users download our file we do not incur these costs.

Design #1 - Compute Engine Google Cloud Platform Compute Engine Logo

Traditionally, to host a file on the internet, we’d have a compute instance running a web server such as Apache or IIS. The server would receive user requests and would deliver the file to the requester.

Costs1 for this solution would be as follows:

Base Cost:

The least expensive instance on Google Cloud Platform (GCP) is the f1-micro. With a 10GB disk in region us-central1 it will cost $4.28/mo.

With a base monthly cost of $4.28, that leaves $95.72 of our budget for usage costs.

Usage Cost:

This design would incur egress data transfer charge per GB transferred. For simplicity we will assume transfer to North America at $0.12/GB.

$95.27 / $0.12/GB = 793GB of data transfer = 793,000 requests for 1MB file.

There are shortcomings of this design beyond cost. A single f1-micro compute instance has shared vCPU and unpredictable performance. There is no redundancy with this design, and we may run into resource constraints; without load testing it is difficult to estimate how much traffic it could handle. Finally, that compute instance will need to be secured, patched, and maintained by someone with OS admin experience.

Design Summary:
Design Base Monthly Cost Requests Serviced with $100 Budget
#1 - Compute Instance $24.70 793k

Design #2 - Cloud Storage Google Cloud Platform Cloud Storage Logo

An alternative to compute instance based hosting would be to use GCP’s Cloud Storage (GCS)2:

Google Cloud Storage is a RESTful online file storage web service for storing and accessing data on Google Cloud Platform infrastructure. The service combines the performance and scalability of Google’s cloud with advanced security and sharing capabilities.

AWS S3 and Azure Files are a similar services.

GCS can solve for some of the reliability and maintenance shortcomings the previous design because it is a hosted service. The cloud platform manages the underlying infrastructure, servers, load balancing, replication, and redundancy. Let’s see how it compares on cost.

Base Cost:

GCS is billed3 based on storage capacity consumed - $.026/GB * 1MB = $.000025/mo

With our $100/mo budget, that leaves nearly all of it ($99.99) for usage based charges.

Usage Cost:

There are two usage based costs to consider with this design.

  • Reads from GCS (Class B operations) - $.004 per 10,000 operations = $0.0000004/read
  • Egress internet traffic - $0.12/GB / 1MB file = $0.0001171875/read

When combined our 1MB file translates to a cost of $0.0001175875/read.

With our remaining budget of $99.99, we can support about 850,000 requests for our 1MB file.

Design Summary:
Design Base Monthly Cost Requests Serviced with $100 Budget
#2 - Cloud Storage $0.000025 850k

Design #3 - Content Delivery Google Cloud Platform CDN Logo

A Content Delivery Network (CDN) is purpose-built for low-latency and low-cost delivery of static content. It acts as a layer on-top of GCS (Described in Option 2) to cache your files in datacenters closest to your customers for quick and inexpensive retrieval.

Estimating CDN cost4 for a service can be challenging. There are multiple factors, including, how diverse your customers are globally and how frequently you update your content.

Optimizing costs and ensuring proper function requires setting cache lifetimes for your content, and requires invalidating CDN endpoint cache when you want to update your content.

We will make some assumptions for the purpose of this estimate.

Base Cost:

There are 3 parts to the base cost of this design.

GCS is still in the design because it is where the base content is stored and accessed by the CDN:

  1. GCS storage capacity used - 1MB @ $0.026/GB = $0.000025/month

Next we will estimate the cost of filling the CDN cache by making some assumptions about our traffic patterns and frequency of content updates.

  1. Reads from GCS (Class B operations) - $0.004 per 10,000 operations = $0.0000004/read
  2. CDN Cache Fill - $.04/GB (North America) @ 1MB file = $0.0000390625/read

If we assume the file is cached at all 31 North America locations and has a cache lifetime of 3 days, that will lead to approximately 300 cache fill activities by the CDN:

(2 + 3) * 300 CDN cache fills = $0.01183875/month

Total monthly base cost based on 1, 2, 3: $0.01186375/month

From out budget of $100/month, that leaves us with $99.98 left to put toward usage.

Usage Cost:

This is where CDN shines compared to previous designs with significantly lower usage costs.

Cache egress cost @ $0.08/GB = $0.000078125/read

At that rate and with our remaining monthly budget we will be able to deliver our file to 1,280,000 users.

Design Base Monthly Cost Requests Serviced with $100 Budget
#3 - Content Delivery $0.01183875 1,280k


In this article we’ve seen how 3 unique solutions can solve for the same problem, while each having unique cost characteristics.

For those with less cloud platform experience, Design #1 may seem ideal for its simplicity and familiarity. But an experienced engineer will look at the long-term costs and maintenance requirements of the solution and will take into consideration other service offerings of the platform.

Design Base Monthly Cost Requests Serviced with $100 Budget
#1 - Compute Instance $24.70 793k
#2 - Cloud Storage $0.000025 850k
#3 - Content Delivery $0.01183875 1,280k

Additional Resources

GCP Overview with a Shoestring Budget Google I/O ‘18 conference - Similar cost-engineering exercise

  1. GCP Compute Engine Pricing ↩︎

  2. GCS Wikipedia Definition ↩︎

  3. GCS Compute Engine Pricing ↩︎

  4. Google CDN Pricing ↩︎