Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru

Optimize Websites Using Cloud CDN on Google Cloud

The Cloud CDN service is able to bring your websites much closer to the end user by caching content at their nearest Edge Point of Presence. This lab will show you how to use Cloud CDN to bring your website "closer" to your end users.


Path Info

Clock icon Intermediate
Clock icon 45m
Clock icon Nov 08, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Deploy Your Environment

    • Open Cloud Shell

    • Copy and paste the below command to build out your HTTP load balanced environment:

      gsutil cp gs://acg-gcloud-course-resources/network-engineer/cdn/ . && source
    • After the script completes, enter the listed frontend IP address in a new tab. It will take roughly 5 minutes after script completion for the load-balanced application to fully initialize. Periodically refresh the website until the correct site displays.

  2. Challenge

    View and Test Performance of Non-Cached Website

    Since our website server is very far away from us, let's see how long it takes to request data from it.

    • In a new web browser tab, enter the frontend IP address, if you have not already done so. Once the website loads, click on the link for Page 2.

    • Depending on your own location, it may load quickly or slowly. If you are in North or South America, the images should load very slowly, because you are very far away from the backend servers.

    • Let's measure the exact performance. Go to Compute Engine, and SSH into your testing-server instance.

    • Once in your instance, run the below commands to send a series of curl requests to both pages of our website and view how long it takes to come back. We will want to reduce these response times via caching.

      • Keep in mind your frontend IP address will be different. Substitute your IP address in the below commands as necessary.

        for i in {1..15};do curl -s -w "%{time_total}\n" -o /dev/null; done
        for i in {1..15};do curl -s -w "%{time_total}\n" -o /dev/null; done
  3. Challenge

    Enable Cloud CDN

    • Leave your SSH window up, and go back to the web console.
    • Go to the top left menu, and select Network Services, followed by Cloud CDN.
    • Select Add origin.
    • From the Load balancer dropdown menu, select http-lb.
    • Your http-backend backend service should be automatically selected. Click Add.
  4. Challenge

    Measure Cached Performance

    It will take a few minutes for your Cloud CDN settings to be fully initialized. Go back to your testing-instance and run the above curl commands again. If you do not get substantially quicker results, wait a few minutes and try again. A few minutes later, repeating the command will show substantially quicker results (about 0.001-0.003 seconds) response time, compared to the 0.19 second responses in the cached version. Repeat this for both your index.html and page-2.html pages.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans