12
votes

We have a web application in App Engine. I was wondering whether it is a good idea to move my static resources (i.e Images, CSS files, and JS files) out from App Engine and serve them from Google Cloud Storage.

My thinking here is two-fold:

1) We can get the advantages of a CDN with Google Cloud Storage. We can even configure metadata for each file to set expiration headers, gzip compression, etc. Also, by serving files from different domains we can have browsers download more content in parallel.

2) By off-loading some of the files from App Engine, the instance consumption is going to decrease (less requests to App Engine), so the costs will go down.

Am I right? Is this a wise move?

Thanks,

3
sounds like a great idea to me!jterrace
HOw will you manage deployment and version control with GCS. At the moment when you deploy new code you are also deploying current static assets. You can test versions and their assets. If you tried to do this with GCS the static resource URL's would have to change each time you deployTim Hoffman
Correct. Basically, static resources that are going to live at GCS have a "special" naming convention. For example: image.v1.png. Every time one of these files change, we rename the file to "image.v2.png". Using this in combination with a 1 year maximum cache, we can get the maximum advantage from browser caching. Most of our deployments are 100% automated, so this process is pretty much well covered. My main concern though is that this adds complexity and I'm not sure if the gains are going to justify it.svpino
#2 is not correct. Static files use a different architecture and dont consume instances.Zig Mandel
This question is still valid, and the answers are fairly old, where do we stand on this now?JLS

3 Answers

7
votes

Neither of these make sense.

1) App Engine has a CDN-like functionality with it's edge cache. Unfortunately, it's not well documented. There's a few Google I/O talks on it. Here's a start: http://eng.pulse.me/backend-tips-the-free-cdn/ There's another talk in Google I/O 2012 that you can find as well. Your static files will be served with the edge cache if they're accessed enough, so no need to move to GCS for this.

2) It's well documented that static files don't take instances. You've already read this, so you 'paranoia' is simply paranoia, and doesn't make sense. It's also very easy to test by uploading a new version onto app engine, accessing a static file, and checking for a new instance in the Admin.

7
votes

You are right, and the answer you accepted is wrong. The answer to your question from the official docs:

https://cloud.google.com/storage/docs/website-configuration

Hosting static assets for a dynamic website

You can use a Google Cloud Storage to host static assets for a dynamic website hosted, for example, in Google App Engine or in Google Compute Engine. Some benefits of hosting your static assets, like images or Javascript files, in a bucket include:

  • Google Cloud Storage behaves essentially like a Content Delivery Network (CDN) with no work on your part because publicly readable objects are, by default, cached in the Google Cloud Storage network.
  • Bandwidth charges for accessing content will typically cost less with Google Cloud Storage.
  • The load on your web servers is lessened when serving the static content from Google Cloud Storage.
3
votes

Your intuition is right, here's the confirmation from Google docs:

The benefits of using Cloud Storage instead of serving directly from your app include:

  • Cloud Storage essentially works as a content delivery network. This does not require any special configuration because by default any publicly readable object is cached in the global Cloud Storage network.

  • Your app's load will be reduced by offloading serving static assets to Cloud Storage. Depending on how many static assets you have and the frequency of access, this can reduce the cost of running your app by a significant amount.

  • Bandwidth charges for accessing content can often be less with Cloud Storage.

Know that static files are definitely served using instance resources. It's true that edge cache comes into effect, but this does not simply remove the whole problem. Moving statics to GCS is the right way of doing this.

Note, however, that if you plan to serve your static files from GCS, you won't be able to properly map a (sub)domain to it over HTTPS (SSL) and you'll have to use a load-balancer or 3rd party CDN. In some cases this may prove to be more of a hassle. See here for details.