将照片存储在 Blobstore 中或作为 Blob 存储在数据存储中 - 哪个更好/更高效/更便宜?
我有一个应用程序,其中特定类型的每个数据存储实体都可以有许多与之关联的照片。 (想象一个汽车销售网站 - 一辆汽车有多张照片)
最初,由于所有数据均来自另一个站点,因此我只能将照片存储为 DataStore Blob,但现在可以通过编程方式写入 BlobStore 项目,我我想知道是否应该更改设计并将照片存储为 BlobStore 项目?
所以,问题是:
将照片存储在 Blobstore 中还是作为 Blob 存储在数据存储中“更好”?两者都是可能的解决方案,但哪一个是更好/更便宜/最有效的方法,为什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与数据存储相比,从 BlobStore 提供的图像具有多个优势:
图像直接从 BlobStore 提供,因此请求不会通过 GAE 前端实例。因此,您可以节省前端实例的时间和成本。
BlobStore 存储成本大约是数据存储存储成本的一半(0.13 美元 vs 0.24 美元)。使用数据存储区,您还需要为 get() 或 query() 付费。
BlobStore 自动使用 Google 缓存服务,因此唯一的成本是带宽成本(0.12 美元/GB)。您还可以通过缓存控制在前端实例上进行设置,但不同之处在于,这是针对 BlobStore 自动完成的。
BlobStore 中的图像可以通过 ImageService 提供,并且可以动态转换,例如创建缩略图。转换后的图像也会自动缓存。
数据存储区中的二进制 blob 大小限制为 1Mb。
BlobStore 的缺点之一是它没有访问控制。任何拥有 blob URL 的人都可以下载它。如果您需要 ACL(访问控制列表),请查看 Google Cloud Storage。
更新:
从成本角度来看,最大的节省来自于正确缓存图像:
每个图像 URL 都应该配备适当的缓存控制 HTTP 标头:
您可以通过以下方式在 java 中执行此操作:
更新 2:
正如 Dan 在评论中正确指出的那样,BlobStore 数据通过前端实例提供服务,因此可以通过用户代码实现访问控制。
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 URL should be served with proper cache control HTTP headers:
you can do this in java via:
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.