存储大量图像 S3 与 DynamoDB [英] Storing a lot of images S3 vs DynamoDB

查看:16
本文介绍了存储大量图像 S3 与 DynamoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理需要每秒存储大量图像的项目.如果我应该将图像存储在 S3 或 DynamoDB 中,我有点困惑.我的困惑是因为 S3 似乎不支持批量请求,如果需要,我必须能够批量获取所有图像;另一方面,我不确定将所有这些图像存储在 dynamoDB 的表中是否是个好主意.最好的方法是什么?

I am working on project that needs to store a lot of images per second. And I'm a little bit confused if I should store my images in S3 or in DynamoDB. My confusion is because it seems that S3 do not support batch requests and I have to be able to get all images in a batch,if necessary; On the other hand I'm not sure if it is a good idea store all these images in a table in dynamoDB. What would be the best approach?

推荐答案

简答:使用 S3.

长答案:DynamoDB 将单个记录限制为 64 KB,因此您可能不能使用 DynamoDB,除非您的图像仍然很小.

Long answer: DynamoDB limits individual records to 64 KB, so you probably can't use DynamoDB unless your images are tiny anyway.

您提到希望在批处理请求中读取图像,但 DynamoDB 批处理请求最多返回 100 条记录或 1 MB(以较少者为准),因此无论如何您都不能一次检索所有图像.您可以通过一次读取一个页面来转储 DynamoDB 中的所有内容,这意味着大量请求一个接一个.不快.

You mention wanting to read your images in a batch request, but DynamoDB batch requests return up to 100 records or 1 MB -- whichever is less -- so it's not like you can retrieve all your images at once anyway. You could dump everything from DynamoDB by reading a page at a time, which means lots of requests one after another. Not fast.

DynamoDB 的延迟低于 S3,并且支持可配置的吞吐量.但是,S3 开箱即用支持尽可能多的并发.想一次上传 1000 张图片吗?去吧!每个对象的写入时间是否为 400 毫秒都没有关系,因为您可以同时传输任意数量的对象.同样,您可以从 S3 中转储所有内容,方法是获取存储桶中所有内容的列表,然后并行检索每个对象.

DynamoDB is lower latency than S3, and it supports configurable throughput. However, S3 supports as much concurrency as you want out of the box. Want to upload 1000 images at once? Go for it! It doesn't matter if each object takes 400 ms to write since you can transmit as many as you want concurrently. Similarly, you can dump everything from S3 by getting a list of everything in the bucket and then retrieving every object in parallel.

使用 S3 的其他原因:

Other reasons to use S3:

  • HTTP 兼容性,因此您可以将其他人或应用程序直接指向存储桶
  • 大大降低存储成本
  • 按请求付费,而不是按预置吞吐量付费(DynamoDB 中 640 KB/s 的写入容量每月花费 460 美元,而 S3 中每 1000 次上传的固定费用为 0.01 美元)

我可以想象 DynamoDB 对图像存储可能有意义的唯一情况是,如果您的图像很小、经常变化,并且您对读取延迟非常敏感.除此之外,请使用 S3.

The only situation I can picture where DynamoDB might make sense for image storage is if your images are small, frequently changing, and you're very sensitive to read latency. Other than that, use S3.

这篇关于存储大量图像 S3 与 DynamoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆