WPMU Object Cache using APC

This is part of the caching for WPMU section of this blog, make sure to browse the other subpages for more information !

WordPressMU comes built-in with an Object Cache. First of all, a small explanation : how is it different from the first two caches we talked about (mysql query cache and PHP cache) ? Well, mysql caches the result sets from SQL queries. The PHP cache caches the compiled version of your scripts in memory. The WPMU object cache is built in the code of WordPress, and it is a way to cache PHP objects (arrays etc.).

For instance, it caches site options, so that it is not necessary to run the same SQL queries everytime you want to fetch these options (which is basically, all the time). Instead these options are put in the cache and read from it systematically. In a similar manner, blog-specific options are stored in the Object Cache. It can save you a lot of SQL queries to use the object cache. The following diagram shows the decrease in number of SQL queries run on one of unblog’s database servers once the object cache was turned on :


Almost 50% less queries than the previous day, without the cache. Great ! So this object cache will lower your SQL load. But wait until you rush turning this on, and read on a bit more.

By default, if you enable the object cache in WPMU, it will use flat files on the disk to store the cached information. Look into the wp-content/cache folder, and you’ll see something along the lines of :


This shows you the structure of the cache on disk (the readable named folders are the global objects caches, the random one contains the cached objects of a given specific blog).

All this is great, but to decide whether or not you want the object cache enabled, you need to be sure that it will actually be positive on your server. Basically, enabling the object cache :

- Results in less SQL queries. In most cases those queries would have been served from the query cache (in memory).

- Results in more disk accesses. Every time the cache is accessed, files are read on disk, and everytime the cache is written, files are written to disk.

The problem is, SQL/memory might not be your architecture’s bottleneck, and disk access might well be. With bloggers constantly uploading and downloading files, hard drives have shown in our experience to be an important bottleneck in performance. In’s architecture, we have made extensive tests with the object cache, which has shown to slightly decrease the load on the database machines (only slightly because most of the queries were served from cache and quite fast), but also slightly increase the load on HTTP servers due to more disk accesses. Since our HTTP servers were more loaded than our SQL servers, we ended up turning off the cache.

So TEST the object cache if you’re going to use the file/disk storage medium. You might end up turning it off.

But wait, is there no way to make this object cache worth a penny ? Actually yes, there is.

The good thing about the object cache is that is allows you to override the default storage medium (files on disk) with your own. This means that with a couple of lines of PHP, instead of storing cached objects on disk, you can do it in memory, for instance by using APC’s user variable cache or the popular Memcached.

Memcached is a distributed system, which means it can be handy if you have multiple load-balanced HTTP servers. However it is slightly slower than APC’s cache, and needs you to run the memcached deamon on all your machines. If you want to go the Memcached route, you can try out Ryan Boren‘s plugin, although be careful because we did not test this with WordPress MU and can’t guarantee it will work as-is. It is known that memcached is the object cache storage used on

For, we have preferred to use APC as our object cache, because it can be used as an opcode cache in the meantime, and because of slightly better performance. We started from the WordPress plugin by Mark Jaquith and modified by Eric Byers and we added some modifications/improvements to make it work better and work with WPMU. The original version was emptying the whole of APC’s cache when flushing cache (including the script caches) instead of just the object cache, and had a couple of other issues.
Download here our version (tested in WPMU). Then drop the object-cache.php file in wp-content, and add :

define(« ENABLE_CACHE » ,true);

to your wp-config.php file.

You will probably need to increase how much shared memory you allocate to APC in order to avoid segmentation faults, as we mentionned here.

This solution will give you optimal performance, by limiting the load on your DB servers, without increasing it on your HTTP servers thanks to the memory storage offered by APC. Champagne !


1 2 3 4 5 14
  1. Wow, this piece of writing is fastidious, my sister is
    analyzing such things, therefore I am going to let know her.

    Feel free to surf to my homepage – vilnius educology university

  2. When someone writes an article he/she keeps the thought
    of a user in his/her brain that how a user can know it.
    Thus that’s why this paragraph is perfect. Thanks!

    Here is my site: plan cul (

  3. Way cool! Some extremely valid points! I appreciate you penning this write-up and also the rest of the site
    is also really good.

    my web-site :: plan cul

  4. Hello, I think your website might be having browser
    compatibility issues. When I look at your website in Firefox, it looks fine but
    when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!
    Other then that, terrific blog!

    Also visit my blog; annonce plan q

  5. So what we should said is the fact that the world thinks that this
    SEC reform overall in the short term could be favorable to us My Website also, if you might be denied credit, you have the right to get a
    free copy of your report in the event you request it within 60 days
    of buying a denial notice.

  6. I am regular visitor, how are you everybody? This post posted at this web site is genuinely fastidious.

    Visit my web blog – power alternative

  7. This is a very good tip especially to those fresh to the blogosphere.

    Brief but very accurate information… Appreciate your sharing this one.
    A must read article!

    Also visit my web blog :: where is the compatibility mode on my computer

  8. Greate article. Keep writing such kind of information on your site.

    Im really impressed by your blog.
    Hello there, You have performed an excellent job. I will definitely digg it and
    for my part suggest to my friends. I’m sure they will be benefited from this site.

    my web page …

  9. Aw, this was a really good post. Finding the time and actual
    effort to create a superb article… but what can I say… I procrastinate a lot and never seem to get
    anything done.

    my weblog: diets (Blythe)

  10. I’m in my first year at university where can i buy essays Chantal Drumgole (née Sanders) an Orange Pride member during the 2003-04 academic year says there was a group within the group « and I am not that kind of girl, a groupie that is just about the football players and trying to sleep with the football players. » A former Orange Pride hostess from the same year who asked not to be named recalls, « People did cross the line. That’s why I was only in the program for one year. … It was very disturbing. When I found out, that’s why I quit. »

  11. I’ve lost my bank card grade my paper online The Europeans are on track to build a new eurozone, one that addresses many of its original design flaws. That means new banking and credit rules, new roles for old institutions, and a new understanding among governments – if not citizens – that Europe needs more unity. In five years, European integration will become something ‘good’ – for international politics and the global economy.

  12. Whereabouts are you from? cash advance stuart fl Today, the demands made by the quarter of a million people who marched on Washington turn 50 years old. Labor leaders such as A. Philip Randolph and Bayard Rustin worked alongside civil rights organizations such as the Southern Christian Leadership Conference and the Student Nonviolent Coordinating Committee to demand jobs and freedom because both economic justice and racial justice were viewed as core civil rights. It was commonly asked at the time, « what good would it do to integrate the lunch counter, if we don’t have the money to buy a hamburger? »

  13. I’d like to open a business account salbutamol ventolin tablet dosage The petition Richard and Lynn Bynes filed Friday not only detail her public incidents of disturbing behavior, including several arrests, but also reveal that the former child star has stated fears that she is being watched by smoke detectors and devices in the dashboard of her car.

  14. I’m doing an internship invited same day no fax payday loans interposed conference « It’s very significant for the political campaign but notfor the enrollment campaign, » said Jon Kingsdale, the formerhead of the Massachusetts state health exchange, which opened in2006 and became the model for Obamacare.

  15. What’s the interest rate on this account? unconscious cash until payday advance registration « The government’s closed — is this bad? » wrote Chen Zhiwu, a user on China’s Twitter-like Sina Weibo. « In the American system, arguments among Republicans and Democrats and the president are normal and should happen because levying taxes, incurring debts, and paying expenses involves the taxpayer’s interests and their money. So, elected representatives and the president should not treat these things lightly. To take these matters seriously is their responsibility and duty. »

  16. I’d like to speak to someone about a mortgage buy cordarone Our 6-foot-2-inch tester reports no misgivings with the driving position, and he hardly notices the 0.9-inch loss of front headroom that comes with the swoopy styling. But the backseat has become largely ceremonial. The rear cabin is 4 inches narrower at the shoulders, 2.6 inches tighter at the hips and there’s 1.3 inches less rear headroom compared to the less-than-spacious Volt.

  17. Who’s calling? best online homework help Quite right, too. The R&A deserves criticism for taking the Open to male-only clubs, if only because the ongoing perception of golf as an elite, sexist sport could put off even one young girl. But the club itself is not breaking any law and it must be suspected they would not be particularly distraught if the R&A did decide to scratch them off the Open roster.

  18. Wonderfull great site keflex and acne Intel’s project, called OnCue, has faced challenges getting off the ground since it was officially launched in February. The chipmaker’s new CEO, Brian Krzanich, ultimately decided Intel could not afford the distraction and expense, sources familiar with the decision told Reuters last week.

  19. Is this a temporary or permanent position? clamp navigation www payday advance com replacement words “I am disappointed with the penalty and intend to appeal and fight this through the process,” Rodriguez said. “I am eager to get back on the field and be with my teammates in Chicago tonight. I want to thank my family, friends and fans who have stood by my side through all this.”

1 2 3 4 5 14

Laisser un commentaire

Le Web Rémunéré |
les codes pokemon |
........l'univers de TINTIN... | | Créer un blog | Annuaire | Signaler un abus |
| riadsfes