APC object caching in combination Batcache/memcached page caching?

The basic rule of thumb for Memcached is: use it if you’re running multiple servers or connecting to multiple databases for the same assets.

Another more harsh way to put it: If you don’t know what Memcached is, you probably don’t need it.

Since you have a single server(and probably single DB) you won’t be able to take advantage of several Memcached features.

Memcached: Distributed memory object caching

APC: Bytecode optimization

You can use a combination of APC and Memcached, you can also use APC with Batcache without Memcached or various combinations of plugins, so it’s a bit confusing.

To clarify Batcache

Batcache has the ability to support Memcached but if you do not have Memcached installed it will still use WordPress’s object cache which is defined in your config.php using define('WP_CACHE', true); and thus APC will take advantage of that.

One advantage of Batcache besides supporting complex server setups via Memcached is it does not write to file , this is why services like WordPress.com use it. Imagine if they had to static cache all their sites, it would be billions of files and impossible to manage via file I/O.

Though Batcache is fairly simple, the execution can be complex, it can be configured as seen by the comments here: http://plugins.trac.wordpress.org/browser/batcache/trunk/advanced-cache.php

To clarify Memcached

Memcached is really meant for multiple servers so they can share and use memory in a intelligent way, in essence they will share a virtual pool of memory. Each node can make use of memory from other nodes (a node does not have to be a traditional web server). Memcache does not care what language you are using since it supports most of them. http://memcached.org/about

To clarify APC

APC in simple terms is single server and PHP only. It stores all the PHP(bytecode) based compiling in RAM.

For a single server

  1. APC + Mark Jaquith’s Dropin + static file cache plugin (super-cache,
    w3-total
    , etc, etc) will net you very fast results. In other words
    APC + a static cache is much faster on a single server then just
    Memcached and/or a non static cache. You can of course combine them
    on a single server, I have never tried that, it’s doubtful there
    will be any improvement. Using Memcached on a single server that already has APC would be like trying to tow a car by hitching the front to the back.

  2. The alternative is to use APC + Batcache instead of a static caching
    plugin, this will most likely give you the same results, just make
    sure you have plenty of ram. This is a fine solution but it requires more server monitoring (imo) than just writing static files because servers are still finicky beasts.

If after doing one of the above and your site is still having issues, then you need to move to a new level with your hardware or start thinking about more complex setups with multiple servers.

Also bear in mind this is not about just general site “speed” but about speed + concurrency.

Don’t optimize for the sake of it.. you will get to a point where optimization does nothing unless there is a demand for it.

Notes:

Each server setup is different and caching is directly tied into the performance of your CPU, RAM, actual code and configurations, so results will vary…there are a lot of configuration options for both APC and Memcached.

It’s important to note that https://github.com/zendtech/ZendOptimizerPlus will probably eventually replace APC.

ps. Test APC out on a dev server before you go live, it often needs fiddling with the configuration or the server might blow up.