GCE: Enable CDN for an existing VM instance / Adding an existing VM instance to a new regional instance group

489 views Asked by At

I have an GCE VM instance running a WP site installed with click-to-deploy. Runs quite well, I managed to get 600ms from Stockholm on pingdom-tools for a page. From US Dallas is not that great: ~4s and from Australia... >6s.

All optimizations are done except for the CDN. Since I'm running in cloud I thought to be easy but I was naive.

I'm trying to enable Google CDN but I got confused in the documentations.

Attempt 1: Tried with creating a load-balancing and adding the bucket from my wp-instance but I failed to get any result. What I have not done is to add the LB IP to my DNS.

Q1: Do I have to do that (IP in DNS)? It's not clear to me.

Attempt 2 Creating an instance group, regional. Sound nice, but I already have an instance, with a fixed IP and a domain connected to it.

Q2: How can I add an existing instance to a new created group? Or can I not?

My WP site is a super simple one, for company-presentation so I don't need computing power. Parallelize downloads of static resources should be enough but, for the sake of learning, I'm willing to go the extra mile and create whatever is required to install the CDN.

Q3: is there a simpler way to create a CDN for static resources only?

2

There are 2 answers

0
SharpBCD On BEST ANSWER

And the answer is:

You can but it's not usefull / you can't for managed instance.

In my personal opinion, Google CDN still needs to grow a bit more.
Main problems:

  • No "origin pull" method
  • No gzip or any other form of processing
  • Every files needs to be set publicly available manually. You can't set folders and there is no recursive propagation within folders structure.
  • I run into very strange errors associated with rights. My instance could copy files from the bucket into the server but could not write. After hours of searching the fix was to set permissions to some file.

About 10 hours of... experimenting. Then I setup a CDN on AWS in literally seconds as copy/paste domain name and a few clicks was all that it required. So maybe it's just me, but I think at this point it's a product that can be improved.

What I tried: I've launch a group of managed instances, installed WP with "hello world" + 1 picture. You do that from cmd line, click-to-deploy is not working here.
Then I did a stress test with BlazeMeter and it autoscaled to 10 instances (or so). Great job on that one.
CDN was enabled but Google Pagespeed was screaming to parallelize downloads and no other domain then the main one was to be spotted in URLs. Also, time to load was the same now as it was before installing the CDN so... not really what I need it.

After that I created another CDN via bucket and it worked as a CDN. However, there is no PULL available. You may copy/paste the relevant files through a nice drag&drop interface. Not good enough so I tried with rsync only to fell in many rights conflicts. Finally it worked. Then I needed to set permission for each file to be publicly available. Folders could not be set so you need to enter each folder, select only files and hit the button. Did that too. Now it's working. But gzip is not supported which cause my overall time to increase. There is no other way around this then to gzip the files yourself and upload them again. Manually.

So I give up and used another CDN that I setup in less then 1 minute.
I believe I need to wait a bit more until Google CDN matures.

1
Stephen Weinberg On

Google's CDN requires load balancing. So you will need to set that up. Specifically, you want:

TargetHttpProxy -> UrlMap -> BackendService -> (Zonal) Unmanaged InstanceGroup -> Your WP instance.

This is how it looks from the API and CLI. If you are using the Web UI, simply setup a normal HTTP load balancer and request zonal and unmanaged for the instance group.

Later, you can just add another unmanaged instance group in another zone (or region) and attach it to the same BackendService for load balancing. It is the BackendService where you enable CDN.


Why a zonal unmanaged instance group?

Well, to start with, only unmanaged instance groups allow you to add instances not created by an InstanceGroupManager. And since the only type of unmanaged instance group is a zonal unmanaged instance group, that is your only option. But that is not too important because you can simply make more instance groups.