Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caching images in Memcached

The user profile images are stored in a separate fileserver, and I am thinking of caching them in memcached. The memcached server is local to the app, and each image is less than 1MB.

But I saw over here that using memcached for images is a bad idea. Is it really? I am really not convinced.

Any best practices and suggestions? I am using SpyMemcached Java Client.

like image 789
Langali Avatar asked Sep 04 '09 16:09

Langali


People also ask

Can you cache images with Redis?

Database query results caching, persistent session caching, web page caching, and caching of frequently used objects such as images, files, and metadata are all popular examples of caching with Redis.

Is Memcache better than Redis?

Architecture. Redis uses a single core and shows better performance than Memcached in storing small datasets when measured in terms of cores. Memcached implements a multi-threaded architecture by utilizing multiple cores. Therefore, for storing larger datasets, Memcached can perform better than Redis.

What is image caching?

Image caching essentially means downloading an image to the local storage in the app's cache directory (or any other directory that is accessible to the app) and loading it from local storage next time the image loads.


1 Answers

Linux automatically caches files that are read from disk. Caching proxies like Squid are also good at caching images.

So... there are certainly are better tools for the job. On the other hand, nginx recently added memcached support. Without context, it's really hard to judge that recommendation.

They might mean "Don't serve images from memcached via a PHP script", in which case, they're absolutely correct -- PHP adds tons of overhead. But I don't necessarily see how using Nginx's memcache feature to store and serve images would be a bad thing.

Edit: It appears that facebook may have cached profile images in memcached at one point.

like image 138
Frank Farmer Avatar answered Oct 29 '22 01:10

Frank Farmer