![](https://cdn.qwiklabs.com/assets/labs/start_lab-f45aca49782d4033c3ff688160387ac98c66941d.png)
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 restart it, you'll have to start from the beginning.
- On the top left of your screen, click Start lab to begin
Create and populate a Cloud Storage bucket
/ 50
Create the HTTP Load Balancer with Cloud CDN
/ 50
In this lab, you configure Google Cloud CDN (Content Delivery Network) 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 the Cache locations resource.
In this lab, you will learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Cloud CDN content can originate from two types of backends:
In this lab, you will configure a Cloud Storage bucket as the backend.
In the Cloud Console, from the Navigation menu click Cloud Storage > Buckets.
Click Create bucket.
Specify values for the following fields, leave all others at their defaults:
Property | Value (type value or select option as specified) |
---|---|
Name | Enter a globally unique name. If the name you enter is not unique, you'll see a message to try another name. |
Location type | Multi-regional |
Location | Choose a location that is very far from you. |
Click Continue.
For Choose how to control access to objects in Prevent public access Dialog box unckeck Enforce public access prevention on this bucket
and click Continue.
Click Create.
Note the name of your storage bucket for the next step. It will be referred to as [your-storage-bucket]
.
Copy an image from a public Cloud Storage bucket to your own bucket.
[your-storage-bucket]
with your bucket's name:Click Authorize.
On the Bucket details page, click Refresh to verify that the image was copied into your bucket.
The recommended practice is to dedicate specific Cloud Storage buckets for public objects.
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). By enabling 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.
cdn-bucket
.Click Frontend configuration.
Specify the following, leave 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.
Click Review and finalize.
Review the Backend Buckets and Frontend.
Click Create and wait for the load balancer to be created.
Click on the name of the load balancer (cdn-lb).
Note the IP address of the load balancer for the next task. It will be referred to as [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 gets cached on the edge of Google's network.
One way to verify that the image gets cached is to time the HTTP request for the image. The first request should take significantly longer as content is only cached at an edge location after being accessed through that location.
The output should look like this example:
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.
In the Cloud Console, from the Navigation menu select Logging > Logs Explorer.
Under the Resources filter, select Application Load Balancer > cdn-lb-forwarding-rule > cdn-lb. Then click Apply.
Click Run Query.
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 log entry towards the bottom of the query results.
Within the entry, expand the httpRequest and notice that the cacheLookup and 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 provided the image on this request, instead of the backend.
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 since the cache of the edge location did not contain the image yet. All other requests were quicker as 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 the Cache locations resource.
For information on the basic concepts of cloud CDN, see Google Cloud CDN Documentation.
Manual Last Updated May 27, 2024
Lab Last Tested May 27, 2024
Copyright 2025 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.