Proof of Concept
We started the process with a POC in which we considered existing running infra compatibilities with services offered by the Google Cloud Platform and also planned for elements in our future roadmap.
Key areas covered in POC:
· CDN introduction
· Creating CDN in Google cloud
Cloud CDN by Google is a low-dormancy content conveyance answer for little to big business.
With in excess of 100 POP (purpose of quality) worldwide and quickened content conveyance utilizing Google’s worldwide premium system make the quickest SSL CDN all around.
The most recent report by Cedexis.
Some of the features of Google Cloud CDN:
· HTTP/2 — it supports latest HTTP protocol for better performance
· Low latency — all contents are served through Anycast (single IP) worldwide
· Logging — it integrates with Stackdriver to provide detailed logging of a request, cache hit/miss
· Purge cache instantly
· Low cost
Wondering why pre-requisite?
Indeed, Google CDN just works with Google load balancer and distributed storage roots. This implies in the event that you are not facilitating your application on GCP (Google Cloud Platform) at that point you can’t utilize their CDN.
As such, it doesn’t bolster outer causes yet. Basic.
So I accept you are facilitating your application on GCP and prepared to utilize a heap balancer (LB) to utilize the cloud CDN.
You got it right; you can’t utilize VM as cause as well. It tends to be empowered distinctly on the heap balancer.
We should kick it off…
I’ve two VM running (one in Singapore and another in the US west). I want to load balance requests to both VM using HTTP load balancer and activate CDN on it.
I need to do the following.
· Create a health check
· Create an instance group
· Create a load balancer
· Enable CDN
Creating a health check
A health check is essential for the load balancer to determine if VM is healthy. When VM can’t respond to the query, then LB would mark that unhealthy and stop sending traffic.
· Login to GCP and go to Health Checks under Compute Engine
· Click “Create a health check.”
· Follow the wizard and enter the necessary information
- Protocol — select HTTP if your application hosted on VM will listen on port 80 and HTTPS for port 443
- Request path — a working context root.
- Health criteria — adjust as necessary
- Click create
It will take few seconds, and you will notice newly created health check on the list. We will use this shortly.
Creating an instance group
Instance group is used in the load balancing setup. It’s called backend services for LB.
· Go to Instance groups under Compute Engine
· Click “Create instance group.”
· Follow the wizard to provide necessary information
- Location — select single-zone as we are not going ahead with an auto-scaling option.
- Zone — choose the zone where VM is running
- Group type — tick unmanaged instance group
- VM instances — select the VM from the list
- Click Create
Repeat the steps for creating an instance group for another VM zone.
Now, we have two instance groups. Each mapped with the VM in the respective zone.
Creating a Load Balancer
· Go to Load balancing under Network services
· Click “Create load balancer.”
- Select the “HTTP(S) load balancing.”
- Enter the name of LB
- Click on “Backend configuration.”
- Click “Create a backend service.”
- Enter the name of the backend services
- Add both instances group which you created earlier as a backend
- Select health check which you created previously
- Session affinity — select if you want the session stickiness
- Click create
- Leave the default configuration in “Host and path rules”. However, if you need conditional forwarding then add as you need.
- Click frontend configuration and enter the name
- Select “create IP address” to get the static IP address. This is important as by default you will get ephemeral IP.
- Protocol, IP version, and port leave it to the default
- Click Done
- Click on review and finalize and if you feel something is wrong then change it else click “Create.”
- Once created, you will notice newly created LB on the list
· This indicates LB is created. Let’s do some test to ensure LB works.
· So, I try to access LB frontend IP, and it’s success!
You may also want to generate some load to ensure traffic is routed to both the VMs. Google will forward requests to the nearest VM from user’s geolocation.
In my scenario, traffic from Asia will go to VM in Singapore and from America, it will go to US-West VM.
Activating Google Cloud CDN
And, finally, it’s time to enable the CDN.
· Go to Cloud CDN under network services
· Click “Add origin.”
· Select the load balancer from origin drop-down and click add
· You should see newly created CDN on the list
This concludes CDN is enabled on the load balancer.
Once you are satisfied with it, you can update your domain’s A record to load balancer global IP.