Does it make sense to use Cloud CDN vs Cloud Storage for reducing cost by caching static content?

Hello, Google Cloud Community !

I am seeking advice on whether it is more cost-effective to use Google Cloud CDN instead of just a Google Cloud Storage bucket for serving static content, particularly images.

In my project, I initially used only a Google Cloud Storage bucket to serve images (Those images are public on the Bucket).

However, I recently switched to using Cloud CDN to try reducing costs when serving static content (images).

I set up a 'Global external Application Load Balancer' with an SSL certificate managed by Google and a 'Backend Bucket' with Cloud CDN enabled. This setup is integrated with the load balancer through an https_proxy rule that directs requests to the backend bucket serving the images.

Additionally, I recently have customized the CDN settings to always respond with the header 'cache-control: public, max-age=31536000'. My intention is to cache static images (which never change) in the user's browser for as long as possible, to avoid repeated requests to the CDN.

However, I've noticed that the cost associated with cache egress, specifically the 'Networking Cloud CDN Traffic Cache Data Transfer to {Region}' metric, is exceeding the costs I previously incurred for object downloads using only Google Cloud Storage.

I'm wondering if there's something wrong with my architecture or configuration.

One of the bases for this decision was that in the region where my application is most requested, the CDN cost with 'Cache data transfer out' / 'Cache Egress' is lower than the 'Worldwide Download' price for the bucket in Google Cloud Storage.

(CDN Cache Data Transfer Out: $0.09 / GB) - For the region my application is most requested
(Google Cloud Storage Multi-Region - Data transfer to Worldwide Destinations: $0.12 / GB)

Could anyone provide insights or suggestions on whether my current approach is cost-effective, or if there are better alternatives?

Thank you for your assistance.

12 3 3,138
3 REPLIES 3

up

I'm developing similar project, I did not find this information in any place. 
Here is my theoretical analysis. Using pricing documentation

https://cloud.google.com/storage/pricing https://cloud.google.com/storage/pricing

TLDR; The CDN Should be a Cost Efficient Solution, I  see around 10%-40% savings.
  

Storage price is fixed and depends on location and type, regardless you use CDN or not.

Read operations are cheap, cost for 1,000 are .0075 for CDN and .004 for Cloud Storage, so read from storage is a bit cheaper.  

But the variable that impacts the most is data transfer. 

Price is $.09 CDN and $1.2 for Storage.

Now, if I apply for my app in a future fictional scenario for monthly price. Here the results.

Conditions

Total Images are 10 GB.

1,000,000  total monthly request

Average image size is 100 KB

Users are from Latin America

_____

The 10GB images cost is  $.2

1,000,000 requests times 100 KB is 100,000,000 KB = 1000 GB = 1TB monthly transfer, doing the math.

 

 StorageTransferReadsTotal
CDN$0.2$90$7.5$97.7
Storage$0.2$120$4$124.2

 

So yes, CDN is cheap, I would say 99% cases, Storage could be cheaper only when the read weight is more relevant, example if you have millions of request for tiny files ( 5kb) like TXT files. 

But there are some pitfalls to consider.
Fill the CDN Cache have a cost too, so files will charge twice the first time they load into the cache and this is happening for TTL period.
Then, I'm not sure about hidden cost, load balancer is required for CDN, I did not find a charge for that.  

Will try my implementation next weeks, will update if I find something. 

Hello @erickeloi ,

It seems like you've set up a robust architecture for serving static content with Google Cloud CDN. However, the unexpected increase in costs associated with cache egress might indicate some misconfiguration or inefficiency in your setup. 

I will also suggest you to check Review Cache Hit Ratio, Optimize Cache-Control Headers, Review CDN Cache Invalidation, Check Request Patterns, Consider CDN Pricing Tiers and  Cost Monitoring and Optimization.