How do I implement Google Cloud CDN?

Cloud CDN from Google is an efficient and low-latency solution for content delivery for small and large-scale businesses.

Introduction

Cloud CDN from Google is an efficient and low-latency solution for content delivery for small and large-scale businesses.

More than 130 POP (point of presence) around the world and an accelerated speed of content delivery through Google's global premium network, Google has created one of the most efficient SSL CDN all over the world. There are many options in Google Cloud Professional Certification. There are numerous possibilities to pick from. Perhaps you've already experienced the benefits of making use of training methods in classrooms as well as within the online environment. In this case it will assist you to retain the information better and will help you complete your training to excel in the realm that is cloud computing.

The most recent report from CDNPerf showing that Google Cloud CDN performs better than Azure, AKAMAI, Cloudflare, Fastly, and many others.

cdn-performancecdn-performanceSome of the capabilities that are available Google Cloud CDN:

  • HTTP/2 is a protocol that supports the most up-to-date HTTP protocol to provide better performance
  • Low latency - all content are delivered via Anycast (single IP) globally.
  • Logging - it works with Stackdriver to give detailed logs of requests, cache hits and miss.
  • Clean cache immediately
  • Low cost

Pre-requisite

Are you wondering why a pre-requisite is necessary?

It's true that Google CDN is only compatible only with Google load balancer and cloud storage sources. If you're not hosting your application through GCP (Google Cloud Platform) it is not able to utilize their CDN.

Also, it does not support external origins as of yet. Simple.

As such, I'm assuming that you're operating your website on GCP and are ready to utilize the load balancer (LB) to connect to Cloud CDN.

It's true; it is not possible to utilize VM as an origin. This can only be enabled by the load balancer.

Let's start...

Scenario

I have Two VM running (one located in Singapore and one located in the US west). I'd like to balance load requests between the two VM with the HTTP load balancer, and then activate CDN on it.

I'm required to complete the following.

  • Create a health check
  • Create an instance group.
  • Create a load balancer
  • Allow CDN

Conducting a health check

Health checks are vital for load balancers to determine if the virtual machine is in good health. If VM isn't able to respond to request, LB will mark it as unhealthy and cease sending traffic.

  • Log into GCP and navigate there to Health checks beneath Compute Engine.
  • Click "Create a health check."
  • gcp-health-check-creategcp-health-check-createFollow the wizard to complete the required details.
    • Choose HTTP if your app is hosted on a VM will be listening on port 80 or HTTPS on port 443 for your application.
    • Request path is a work context's root.
    • Health requirements - adjust as required
  • gcp-health-checkgcp-health-checkClick Create

It'll take just about a minute to complete, and you'll see the newly-created health assessment on the list. It will be utilized in the next few minutes.

The creation of an instance group

Instance groups are employed for load balancing purposes. It's referred to as"backend" services in LB.

  • Visit the Instance group in the Compute Engine.
  • "Click" to "Create the instance group."
  • gcp-create-instance-groupgcp-create-instance-groupFollow the wizard to give the required information.
    • Location - Choose a single-zone since we're not going to use auto-scaling.
    • Zone - select the zone in which VM runs.
    • Type of Group - tick the unmanaged instance group
    • VM instances - choose one VM on the left.
  • Click to create

gcp-instance-groupgcp-instance-groupRepeat the steps to create an instance group for a different VM zone.

There are two instances. Each is mapped to the VM within the zone of its respective.

Making a Load Balancer

  • Go to Load Balancing under Network services.
  • Click "Create load balancer."
  • gcp-create-lbgcp-create-lbChoose the "HTTP(S) load to balance."
  • Input the name of LB
  • Select "Backend setting."
  • Click "Create an online Backend Service."
  • Name the Backend service
  • Include both instances in the group you previously created as an backend
  • Select the health check that you made previously
  • Session affinity - choose whether you would like the session to remain sticky.
  • Click to create
  • gcp-create-backendgcp-create-backendYou can leave the default configuration in "Host and rules for paths." But, if you need conditional forwarding then you can add it as needed.
  • Go to the frontend configuration, and then enter the name.
  • Choose "create an IP address" to obtain a fixed IP. This is crucial because in default, you will be given an the ephemeral IP.
  • Protocols, IP version, and port remain to default.
  • Click Done
  • gcp-front-end-lbgcp-front-end-lbReview and then finalize If you believe that something is not right, make it right by clicking "Create."
  • gcp-front-end-lb-creategcp-front-end-lb-createAfter the LB is created, you'll see a that it is a newly established LB listed on your list.

gcp-lb-createdgcp-lb-createdThis is a sign that LB is made. Let's run some tests to make sure LB is working.

Therefore, I try to connect to LB frontend IP and it's successful!

gcp-lb-worksgcp-lb-worksIt is also possible to create load to ensure that traffic is directed to both virtual machines. Google forwards requests to the closest VM depending on the location of the user.

If I were to imagine my situation, all traffic coming from Asia will be sent through VM in Singapore as well as from America the traffic will be sent to the US-West VM.

Activating Google Cloud CDN

It's time to activate the CDN.

  • Visit Cloud CDN under the network services.
  • Click "Add Origin."
  • gcp-cdn-add-origingcp-cdn-add-originChoose the load balancer in the Origin drop-down, then click Add.
  • gcp-add-cdngcp-add-cdnThere should be a newly-created CDN listed on this page.

google-cloud-cdngoogle-cloud-cdnThis is the end of CDN is turned on in the load balancer.

When you are satisfied with it, you may change your domain's A record to make it a load balancer's worldwide IP. If you're seeking for more detailed info about GCP, it is accessible by a thorough preparation through GCP certification cost in India.


Varun Singh Rajput

24 Blog posts

Comments