views:

1237

answers:

1

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.

+3  A: 

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.

Frank Farmer
I am already using memcached for my application and storing of a lots of stuffs, and hence the temptation to go with Memcached for images rather than using other ways meant esp for caching files.
Langali
Be warned: apache can serve images from disk in less than the time it takes your PHP framework to start up.Benchmark it yourself, but you'll find that webservers are really good at serving flat files.
Frank Farmer
I have 3 apache servers in front of 3 tomcat instances, talking to a separate fileserver. Ideally I would just offload it to CDN or even store local to apache, but I need to protect access to those images based on roles. That limits me to server it from tomcat. And hence a distributed cache in the same network is why Memcached makes sense to me. I will see what my benchmarks say.
Langali