本文介绍了将照片存储在Blobstore中或作为数据存储区中的Blob存储 - 哪种更好/更高效/更便宜?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序,其中某个特定类型的每个DataStore实体都可以有多个与其关联的照片。 (想象一下一个汽车销售网站 - 一辆汽车有多张照片)
原来由于所有数据都是从其他网站获取的,因此我只能将这些照片存储为DataStore的斑点,但现在它可以编写BLOBSTORE项目编程,我想知道如果我要改变我的设计和照片存储为BLOBSTORE项目?
因此,问题是:
将照片存储在Blobstore中或作为数据存储区中的Blob是否更好?这两种解决方案都是可能的解决方案,但是这将是更好/更便宜/最有效的方法,为什么?
与数据存储相比,它有以下几个优点:图像直接从BlobStore提供,所以请求不通过GAE前端实例。因此,您需要节省前端实例的时间和成本。BlobStore的存储成本大约是数据存储成本的一半(0.13美元vs 0.24美元)。使用Datastore,您还需要支付get()或query()。
BlobStore自动使用Google缓存服务,因此唯一的成本是带宽成本( $ 0.12 / GB)。您还可以通过缓存控制在前端实例上设置此功能,但不同之处在于,这是针对BlobStore自动完成的。
BlobStore中的图像可通过ImageService并可以,例如创建缩略图。转换后的图像也会自动缓存。
ol>
BlobStore的一个缺点是它没有访问控制。任何有blob网址的人都可以下载它。如果您需要ACL(访问控制列表),请查看。
更新:
成本方面,最大的节省来自正确缓存图像: p>
- 每张图片都应该有一个永久性的网址。
$ b // 32M秒有点超过一年
Cache-Control:max-age = 32000000,必须重新验证
您可以通过以下方式在java中执行此操作:
httpResponse.setHeader(Cache-Control,max-age = 32000000,must-revalidate);
更新2:
正如Dan在评论中正确指出的那样,BlobStore数据通过前端实例提供,因此访问控制可以通过用户代码实现。
I have an app where each DataStore Entity of a specific kind can have a number of photos associated with it. (Imagine a car sales website - one Car has multiple photos)
Originally since all the data is being sourced from another site, I was limited to having to store the photos as DataStore Blobs, but now that its possible to write BlobStore items programatically, I'm wondering if I should change my design and store the photos as BlobStore items?
So, the question is:
Is it 'better' to store the photos in the Blobstore, or as Blobs in the Datastore? Both are possible solutions, but which would be the better/cheaper/most efficient approach, and why?
解决方案
Images served from BlobStore have several advantages over Datastore:
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.
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().
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.
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.
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:
- Every image should have a permanent URL.
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.
这篇关于将照片存储在Blobstore中或作为数据存储区中的Blob存储 - 哪种更好/更高效/更便宜?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!