Problem
I read this post a long time ago: http://www.mysqlperformanceblog.com/2006/09/27/apc-or-memcached/. I’d like to use the finest caching engine available so that my program runs as quickly as possible. Of course, I don’t want to cache excessively, but I do want to select the best option available. Memcached is sluggish, while apc is quick, according to that article, so why is everyone using Memcached?
http://framework.zend.com/manual/en/zend.cache.backends.html#zend.cache.backends.twolevels “Use a fast (but limited) one like Apc, Memcache… and a “slow” one like File, Sqlite…”, it advises. Do you believe it’s a smart idea to use Apc for the fast and Memcache for the slow?
Asked by Thomaschaaf
Solution #1
APC is a non-distributed opcode cache, whereas Memcached is a distributed caching system.
You must utilize memcache for distributed caching if (and only if) you have a web application that must live on multiple webservers (loadbalancing). If not, simply rely on APC and its cache.
Always make use of an opcode cache, such as APC (also APC will get integrated into php6 iirc, so why not start using it now).
Both can (and should) be used for distinct objectives.
Answered by Karsten
Solution #2
Memcached if you need to preserve state across several web servers (if you’re load balanced and it’s important that what’s in the cache is the same for all servers).
APC if you just need access to quick memory to read (& write) on a (or each) server.
Remember that APC can compile and speed up the execution of your script. As an example, you could use APC for better execution performance and memcached for cache storage.
Answered by 2 revs
Solution #3
The opcode cache is APC’s key advantage. It’s not an official announcement because PHP 5.5 incorporates OpCache into its core and APC for PHP 5.4 is still in beta, however APC development will be discontinued in the near future.
So I would recommend you to choose Memcached.
Answered by Hieu Vo
Solution #4
I use both for speed and to keep all of my servers in sync. If you’re going to use memcache, keep in mind the open ports that you’ll need to block with iptables.
Answered by Saimon Lovell
Solution #5
Hello there, Thomaschaaf. I hope this utility arrives in good time for you, however please be aware that APC has some issues with “user-cache.” To cut a long tale short, you may experience issues if you set time-outs for cache entries or if your apache dies inside internal APC code (for example, timeout).
http://nirlevy.blogspot.com/2009/06/apc-futexwait-lockdown-make-your-apache.html is a blog post I wrote about the subject, and you should also read http://t3.dotgnu.info/blog/php/user-cache-timebomb.html. (I believe from one of the APC developers)
Answered by Nir Levy
Post is based on https://stackoverflow.com/questions/815041/memcached-vs-apc-which-one-should-i-choose