Store Photos in Blobstore or as Blobs in Datastore - Which is better/more efficient /cheaper?

巧了我就是萌 提交于 2019-11-27 10:45:22
Peter Knego

Images served from BlobStore have several advantages over Datastore:

  1. Images are served directly from BlobStore, so request does not go through GAE frontend instance. So you are saving on frontend instances time and hence cost.

  2. BlobStore storage cost is roughly half of Datastore storage cost ($0.13 vs $0.24). With Datastore you'd additionally pay for get() or query().

  3. BlobStore automatically uses Google cache service, so the only cost is cost of bandwidth ($0.12/GB). You can also set this on frontend instance via cache control, but the difference is that this is done automatically for BlobStore.

  4. Images in BlobStore can be served via ImageService and can be transformed on the fly, e.g. creating thumbnails. Transformed images are also automatically cached.

  5. Binary blobs in Datastore are limited to 1Mb in size.

One downside of BlobStore is that it has no access controls. Anybody with an URL to blob can download it. If you need ACL (Access Control List) take a look at Google Cloud Storage.

Update:

Cost wise the biggest saving will come from properly caching the images:

  1. Every image should have a permanent URL.
  2. Every image URL should be served with proper cache control HTTP headers:

    // 32M seconds is a bit more than one year 
    Cache-Control: max-age=32000000, must-revalidate
    

you can do this in java via:

httpResponse.setHeader("Cache-Control", "max-age=32000000, must-revalidate");

Update 2:

As Dan correctly points out in the comments, BlobStore data is served via a frontend instance, so access controls can be implemented by user code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!