navigation

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 :

mysqlload.jpg

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 :

cache.jpg

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 unblog.fr’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 wordpress.com.

For unblog.fr, 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 !

Commentaires»

1 11 12 13
  1. There is no doubt that engaging people on the right social media platform can help you reach a new
    audience and increase your online profile.

    Take a look at my web-site: social network websites

  2. I always spent my half an hour how to have a strong penis read
    this website’s articles all the time along with a cup of coffee.

  3. Once a site is submitted to the search engine, the robots, also often known as search
    engine crawlers or search engine spiders, analyze the content of a site as well as other search engine criteria such as the accuracy of the website coding (ie: clean coding) to establish content relevance and overall website relevance.
    If you want to give a service onn the web this works much the same way.
    If you want ideal client David to join your latest teleseminar, save the
    share buttons for your confirmztion page.

    My site … Rocket Builder bonus

  4. There are also rites to earn, and collection items that trade in for better
    equipment. Why risk getting more expensive and costly troops killed in an attack
    if you don’t have to. In fact, as successful as Clash of Clans is,
    it only ranks #1 for the keywords.

    Feel free to surf to my weblog; clash of clans hack tool online

  5. I am regular visitor, Һow are you evеrybody?
    Thiѕ article posted att tɦis site іs aсtually
    fastidious.
    http://social.himeshsharma.com/index.php?a=profile&u=brandondang

  6. I haνe bеeո exploring forr ɑ biit for any Һigh quality articles
    οr weblog posts iո tɦiѕ soort of house . Exploring in Yaho ӏ
    at lаst stumled upon this web site. Reading tɦis info Sо i’m happy tߋ
    show that I’ve a vеry excellent uncanny feeling I came upon exɑctly whɑt I needed.
    I most unquestionably ѡill makе ѕure to ɗߋ noot disregard tɦіs site and provides it a look on
    a relentless basis.
    http://www.lq-light.com/blog/member.asp?action=view&memName=DedraBeak0491798940

  7. Todаү, whіle I was at wоrk, myy cousin stole mʏ iphone ɑnd tested to seе if
    it caan survive a 40 foot drop, ʝust soo sɦе can bee a youtube sensation.
    Ϻy iPad is noѡ broken аnd she ɦas 83 views. І kbow tҺіs
    is compleely оff topic Ƅut Ӏ had to share іt withh ѕomeone!

    http://chulbuli.in/profile/DelorisSto

  8. You can gain the cooperation of the city’s key figures by either bribing them, or blackmailing
    them, or using extreme force to convince them to support your cause.
    Be a friend to your child and play the games with him or
    her. They can help you figure out which games are in your genre and fit your
    requirements.

    Also visit my web blog: webpage [Kelvin]

  9. There are also rites to earn, and collection items that
    trade in for better equipment. Also a Tap4Fun game, released in 2014, which takes place in the ancient city of Sparta.
    Players rally an army ofdragons and wizards, and barbarians about them, develop
    clans, and make communities.

    Here is my web-site :: web page (Gloria)

  10. There are also rites to earn, and collection items that trade in for
    better equipment. Observe for any of his physical or behavioral changes.

    I don’t have a problem with surveys, but I understand the concerns.

    Also visit my web page … clash of clans hack tool online

  11. Examiner: What did you play as a game, how did it play a role in this game.
    Have you ever tried the most classic mobile strategy games Clash of Clans and Boom Beach.
    In fact, as successful as Clash of Clans is, it only ranks #1 for
    the keywords.

    Check out my page; clash of clans hack tool online (Isis)

  12. You can initialize unlimited gold, elixir, gems and others simply once they know
    the clash of clans cheats. Not using codes allows you to get
    the most from the enjoyment intended by the
    creators. ), this also means that developers have opportunities to display more in-game advertising
    as well as offer more in-app purchase options.

    Also visit my blog post … clash of clans hack tool
    online (aboutjonny.blogspot.com)

  13. This Boom Beach is really worth your time and effort. Why risk
    getting more expensive and costly troops killed in an attack if you don’t have
    to. In fact, as successful as Clash of Clans is, it only ranks #1 for the keywords.

    my webpage … clash of clans hack tool online

  14. Where Vinci features the great civilizations from Earth’s history, the stars of Small World all come from the fantasy world.
    These can be really helpful, as they always review the hottest games.
    You can buy pets, furniture and electronics to increase your happiness and relaxation.

    My website :: web site (Willie)

  15. Desenvolvimento ficou ao encargo da Gearbox Software,
    empresa que já teve experiências não só no gênero shooter mas também com outros estilos, como Tony Hawk Pro Skater three.

    Feel free to surf to my weblog 50dollars psn codes free

  16. Los BIN por si solos son inofensivos hasta cierto grado aunque ponen en evidencia gran característica de las tarjetas, para que alguien use
    in-adecuadamente tiene que GENERAR TARJETAS de la
    forma anterior, todo basado en patrones.

    My web-site: generador de tarjetas de credito con codigo de seguridad y fecha de caducidad

  17. Oh my goodness! Amazing article dude! Many thanks, However
    I am experiencing difficulties with your RSS. I don’t know why I can’t
    subscribe to it. Is there anybody getting identical RSS
    problems? Anyone who knows the solution can you kindly respond?
    Thanx!!

    My web site – seo optimization

  18. Hmm is anyone else having problems with the pictures on this blog loading?
    I’m trying to determine if its a problem on my end or if it’s the blog.
    Any feed-back would be greatly appreciated.

    My web site … Rsync

1 11 12 13

Laisser un commentaire

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