What's the best way to use memcache with a single-server app? What's the best way to use memcache with a single-server app? linux linux

What's the best way to use memcache with a single-server app?


Usually, the recommendation (see What about shared memory? in the memcached page) is to run memcached on the same machines as web servers, on the premise that web applications are CPU-heavy (which memcached is not), whereas memcached is memory-heavy (which most web applications are not, at least in comparison).

So, if your web server has plenty of memory, it's a good idea to run memcached on it. YMMV.


Another option to memcached - depending on the scale on information you are caching, is caching in APC. You should be running that (or a similar op-code cache) to help speed the PHP page delivery anyhow, so if you are caching somewhere from a few, to a hundred or more smaller (I've got a few at around 15KB each, out of more than 70) variables at a time, you may find some benefit to storing them in APC.

I've got a site that caches some DB lookups, and also caches a post-parsing config.ini file - and on my (busy) site, I'll save literally millions of potential DB hits per day.