
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create and populate a Cloud Storage bucket
/ 5
Create the HTTP Load Balancer with Cloud CDN
/ 5
In this lab, you configure Cloud Content Delivery Network (Cloud CDN) for a backend bucket and verify caching of an image. Cloud CDN uses Google's globally distributed edge points of presence to cache HTTP(S) load-balanced content close to your users. Caching content at the edges of Google's network provides faster delivery of content to your users while reducing serving costs.
For an up-to-date list of Google's Cloud CDN cache sites, refer to this documentation: https://cloud.google.com/cdn/docs/locations
In this lab, you learn how to perform the following tasks:
For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
Cloud CDN content can originate from two types of backends:
In this lab, you configure a Cloud Storage bucket as the backend.
[your-storage-bucket]
.Copy an image from a public Cloud Storage bucket to your own bucket.
In the Cloud Console, click Activate Cloud Shell ().
If prompted, click Continue.
Run the following command in Cloud Shell, replacing [your-storage-bucket]
with your bucket's name:
In the Cloud Console, click Refresh to verify that the image was copied.
Publish Cloud Storage image file to the web with following command:
In the Cloud Console, click Refresh to verify that "Public to internet Copy URL" now appears under the column called Public access.
Click on Copy URL under Public access to verify that you can access the image.
Exit Cloud Shell:
Click Check my progress to verify the objective.
HTTP(S) load balancing provides global load balancing for HTTP(S) requests of static content to a Cloud Storage bucket (backend). When you enable Cloud CDN on your backend, your content is cached at a location at the edge of Google's network, which is usually far closer to the user than your backend is.
The host and path rules determine how your traffic will be directed. For example, you could direct video traffic to one backend and image traffic to another backend. However, you are not configuring the Host and path rules in this lab.
Click Frontend configuration.
Specify the following, leaving all other values with their defaults:
Property | Value (type value or select option as specified) |
---|---|
Protocol | HTTP |
IP version | IPv4 |
IP address | Ephemeral |
Port | 80 |
Click Done.
[LB_IP_ADDRESS]
.Click Check my progress to verify the objective.
Now that you have created the HTTP load balancer for your bucket and enabled Cloud CDN, it is time to verify that the image is cached on the edge of Google's network.
One way to verify that the image is cached is to time the HTTP request for the image. The first request should take significantly longer, because content is only cached at an edge location after being accessed through that location.
The output should look like this (do not copy; this is example output):
Another way to verify that the image got cached in the previous step, is to explore the Cloud CDN logs. These logs will contain information on when content was cached and when the cache was accessed.
Expand the first log entry (on top).
Within the entry, expand the httpRequest and notice that the cacheLookup is true but there is no cacheHit field.
This illustrates that the cache did not contain the image on this first request.
Expand the jsonPayload and notice that the statusDetails field contains response_sent_by_backend.
This also illustrates that the image came from the backend bucket on this first request.
Close the current log entry and expand a different log entry.
Within the entry, expand the httpRequest and notice that the cacheHit is true.
This illustrates that the cache contained the image on this request.
Expand the jsonPayload and notice that the statusDetails field contains response_from_cache.
This also illustrates that the cache, instead of the backend, provided the image on this request.
In this lab, you configured Cloud CDN for a backend bucket by configuring an HTTP load balancer and enabling Cloud CDN with a simple checkbox. You verified the caching of the bucket's content by accessing an image multiple times and exploring the Cloud CDN logs. The first time you accessed the image, it took longer because the cache of the edge location did not contain the image yet. All other requests were quicker because the image was provided from the cache of the edge location closest to your Cloud Shell instance.
For an up-to-date list of Google's Cloud CDN cache sites, refer to this documentation: https://cloud.google.com/cdn/docs/locations
When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
Manual Last Updated: May 14, 2024
Lab Last Tested: May 14, 2024
Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one