On Sun, Jul 5, 2009 at 2:43 AM, Paul Scott<pscott@xxxxxxxxx> wrote: > Eddie Drapkin wrote: >> if you want a pure opcode cache, APC is a great choice. >> >>> you think this is similar to http://www.danga.com/memcached/ or you think >>> this method would be faster ? Which do you say would be the greatest >>> benfit ? >>> > A simple rule of thumb that I use is: > > If you have one machine and medium to large traffic loads, go APC > If you have more machines for caching servers (dedicated) and large to > holy mofo loads, then go MemcacheD > > This ALL assumes that you have followed a logical scalability plan and > have separate DB servers, app servers and possibly even using a CDN or > something beforehand. > > -- Paul > > http://www.paulscott.za.net/ > http://twitter.com/paulscott56 > http://avoir.uwc.ac.za > There are several problems with using APC instead of memcached, even on a single machine: 1) APC is tied to the wbserver. This brings up a lot of (not so) obvious problems. The processing is handled by the webserver, instead of a dedicated process. This can mean that a CPU intensive APC operation ties up the webserver, which results in less concurrency for your site, while just waiting to hear back from memcached means idle webserver process, which allows for greater concurrency. 2) APC is designed to be an opcode, first and foremost. And while it may perform as well, or better, on infrequently modified data, memcached is designed and optimized internally to map memory chunks and utilize best memory management practices, which mean data that changes frequently is better stored in memcached. There's a slideshow somewhere about facebook's internal caching, and they store things like school names / info in APC, because fetching it is a tad faster (especially localhost v. network), but the constant rewiring of webserver memory is a bad idea, so they store data that changes often (like status updates) in memcached. 3) memcached has a much richer, better API. Things like CAS can solve race conditions, while APC cannot. There's also increment/decrement, replace, etc. etc. 4) APC shares its memory between storage and opcodes, afaik. So, you fill up APC too much and you start to lose your cached opcodes? I'd rather not. 5) APC, once again, is tied to the webserver, so a webserver restart means you either have to a) prime your cache or b) let your database be hammered while you "live prime" the cache. Neither of these are particularly pleasant, as cache priming is a very difficult task, while allowing direct read access to the database on all pageloads is usually a problem when you have to have a key-val cache system in place. Long story short, if you're using some sort of RAM based cache to store heavy data, use memcached, while light data (configuration values read from a text file, maybe) are fine in APC. --Eddie -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php