google-cloud-platformgoogle-compute-enginenetwork-trafficgoogle-cloud-cdnegress

Understanding GCP egress costs. Will implementing google cdn help to cut down the costs


I'm quite new to GCP and tried to set up a website on the GCP compute engine. I was aware of egress charges but never thought I will get so much fake traffic from China. I thought of blocking all the traffic from China. But I felt, it would not be the right thing to do. I would like to understand how egress traffic bills a webpage. This may sound amateur or funny, please bear with me.

Scenario 1: Let's assume I have 2 MB size of images in my webpage, and a 20kb html file with youtube video; are in compute engine. I understood that the egress traffic will be calculated on the 2 MB images and 20 kb transferred. But when I/someone play a youtube video that is embedded in the html, is it considered as egress traffic as well?

Scenario 2: The files size is same as above, now, the images are shifted to CDN/Cloud storage and only the html file of 20kb with youtube video is in compute engine. If someone try to access the webpage, will they calculate compute engine egress charges based on the total transfer of 2MB images and 20kb html file? or just the 20kb of html file?

Note: This is not just to cut costs on the billing, I'm just trying to create a effective solution without blocking a country's access to my website. I'm trying to understand the egress traffic from a few days, but I'm not sure if I really understood the core concept.


Solution

  • Based on your scenarios, there are two types of egress involved here, Compute Engine/Cloud Storage and Google Cloud CDN with different costs. For China, costs are almost double. Please refer to following google docs:

    https://cloud.google.com/cdn/pricing#cloud-cdn-pricing https://cloud.google.com/vpc/network-pricing#internet_egress

    Scenario 1: You will be charged for 20 MB + 20 Kb Compute egress. For youtube video, you don't have to pay egress as user's browser will be playing it from youtube servers

    Scenario 2: If you put in Cloud Storage, egress costs will be same as Scenario 1. But, if you put in Cloud CDN, then costs will become lower.