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?
The more efficient and cost-effective option is to use AWS's S3 service for storing the image files. Using S3 is a very low-cost option. Effectively, all you are paying for is transferring files into an S3 bucket and serving those images to your users.
For relatively small items, especially those with a size of less than 4 KB, DynamoDB runs individual operations faster than Amazon S3. DynamoDB can scale on-demand, but S3 offers better scalability.
Long answer: DynamoDB limits individual records to 64 KB, so you probably can't use DynamoDB unless your images are tiny anyway.
Taking all of this into account and adding up our original AWS bill, we can easily say that the DynamoDB solution is cheaper by more than 10x than the S3 solution.
Short answer: Use S3.
Long answer: DynamoDB limits individual records to 64 KB, so you probably can't use DynamoDB unless your images are tiny anyway.
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 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.
Other reasons to use 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With