Redis for caching image files

amazon s3amazon-elasticachecachingmemcachedredis

I am using Amazon S3 for storing and retrieving images for an image storing website.
The trouble is that multiple users have to retrieve same image multiple times.

Is it suggested to use Redis or memcached for caching image files by storing them directly onto it.

Amazon S3 pricing for data transfer is much higher than compared to serving images via Redis cache. But storing image files directly on Redis seems to be a bad proposition because I read somewhere that Redis is not good for operating on large data files. Also I don't understand that if Redis stores data on memory how will it store so many images(unless I make many many instances).

Is it advisable to store image files directly onto Redis or is there an alternate for caching these images?

Do pinterest and imgur use Redis and memcache for storing images directly? If not why do they have so many instances?Pinterest

Best Answer

You get credit for creativity, but you have not found a loophole, here.

First, it's entirely inappropriate to try to serve images from elasticache. It's a cache. It's volatile by definition.

Second, it's not a web server.

Third, it's not intended to be exposed to the Internet.

But even if these aren't persuasive, your question seems premised on a misunderstanding of the pricing structure on several levels.

There is no Amazon ElastiCache Data Transfer charge for traffic in or out of the Amazon ElastiCache Node itself.

https://aws.amazon.com/elasticache/pricing/

Technically, this is accurate, but it is not helpful.

This is only relevant to the transfer from elasticache to your EC2 instance. You still have to return the data to the browser, across the Internet, and this costs the same, whether you return it from/through EC2, or from S3.

Data Transfer OUT From Amazon EC2 To Internet

Up to 10 TB / month $0.09 per GB

https://aws.amazon.com/ec2/pricing/

...or...

Data Transfer OUT From Amazon S3 To Internet

Up to 10 TB / month $0.090 per GB

https://aws.amazon.com/ec2/pricing/

Meanwhile, CloudFront is $0.085/GB for traffic sent to browsers that are accessing edge locations in the lowest price class, US and Europe. And you control which edge locations are available when you select a price class other than the global one:

If you choose a price class that does not include all edge locations ... you're charged the rate for the least expensive region in your selected price class.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/PriceClass.html

That's $0.085 if configured correctly.

There is no charge for transfer from S3 to CloudFront or from EC2 to CloudFront. Only the charge from CloudFront to the Internet.