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

查看:104
本文介绍了存储大量图像S3 vs 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的其他原因:


  • 与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 vs DynamoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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