Should I move my static resources from App Engine to Google Cloud Storage?

前端 未结 3 1997
清酒与你
清酒与你 2021-02-20 04:25

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 serv

相关标签:
3条回答
  • 2021-02-20 04:52

    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.

    0 讨论(0)
  • 2021-02-20 04:56

    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.
    0 讨论(0)
  • 2021-02-20 05:01

    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.

    0 讨论(0)
提交回复
热议问题