XCache and eAccelerator Plugins for WordPress

In this episode of "The Never-Ending Quest for Better Server Performance," we follow our heroes' journey through the dangerous and murky woods of PHP opcode caching engines, where they aren't content with just installing an opcode caching engine, but <gasp> becoming one with it too!

Yep, you heard that right. We've just released two new plugins for the WordPress users out there, that take opcode caching to the next level. If you haven't already installed an opcode caching engine like XCache (our favorite!), eAccelerator, Turck MMcache, Memcached, APC, or PHPA then you really need to do that right now before even continuing this article. Really, what were you waiting for!?

Now that you've discovered the joy of opcode caching and the benefits it brings to your servers, here comes the next step: integrating the actual code your server runs with your opcode caching engine. By default, when you install the opcode cacher, it'll sit in the background (in the memory!!!!) and memorize what each compiled PHP script looks like. Sure, it's a lot of work, but it can be doing even more - like memorizing objects and variables in its uber-fast memory too.

The problem is that this isn't something "easy" that happens by itself, it requires a conscious and painful effort on behalf of script developers to add an integration layer in their script that lets it communicate with the opcode caching engine. Well, that's what we've done for all you WordPress lovers out there: we've added support for the two very popular open-source opcode caching engines - XCache and eAccelerator. Both are very good opcode cachers in their own right, but with our WordPress extensions, they become Godsends.

Installation is a snap: just extract the single PHP file for your engine, and stick it in your /wp-content/ folder to discover the truly powerful side of opcode caching! You can use these on dedicated and shared hosts, just figure out what caching engine is in use and download the appropriate file.

Download XCache for WordPress

Download eAccelerator for WordPress



Leave a Reply  •  About to Ask for Help?  •  Subscribe to Our Feed

50 Responses to “ XCache and eAccelerator Plugins for WordPress ”


  1. 1Reaper-XSep. 16th, 2007 at 3:54 pm

    Thanks a lot for this :) ... tested on localhost and live blog, and it works great (which is the same like Wordpress built-in object cache with the exception this time the cache is not located at the default location)

  2. 2Computer GuruSep. 16th, 2007 at 4:07 pm

    That's good news!

    Did you use eAccelerator or XCache? Apache or IIS? Windows or Linux?

    It's actually the same thing as the in-built object cache, except it stores the stuff in the memory instead - hundreds of times faster! We're using it here with XCache now, it seems to be working just fine :)

  3. 3Reaper-XSep. 16th, 2007 at 4:35 pm

    Ahh forgot to tell you that, i ran Linux with XCache (dont mind the header lol), and yes i do notice that it works like Object Cache, because if a page has not been visited before it'll show high query usage but when the same page gets visited again it'll show you less query usage (my homepage shows more than 95+ queries at first start before it gets cached, and then goes to 17 queries, and for now it just using 14 queries) .. that means it works !!!

    btw .. it'd be great if you could create some special page for this plugins to make sure that everyone get the latest update :P

  4. 4Computer GuruSep. 16th, 2007 at 4:40 pm

    Thanks for sharing that info (XCache rocks! :)). Not sure I understand what you mean by "special page" though... Do you mean a page in the WP-Admin Dashboard or here on the site?

  5. 5Reaper-XSep. 16th, 2007 at 4:46 pm

    Ah .. i mean a special page dedicated for this plugin, for example like http://neosmart.net/blog/wordpress-xcache ;)

  6. 6Computer GuruSep. 16th, 2007 at 5:06 pm

    Well, the dedicated page for the XCache plugin is http://neosmart.net/dl.php?id=12 and for the eAccelerator one it's http://neosmart.net/dl.php?id=13.

    We're still working on our software archive center which will feature a searchable archive of all our previous works and link to their appropriate pages (each is dl.php?id=somenumber).

  7. 7Reaper-XSep. 16th, 2007 at 5:28 pm

    Bookmarked !

    We’re still working on our software archive center which will feature a searchable archive of all our previous works and link to their appropriate pages (each is dl.php?id=somenumber).

    I guess that's okay because i can always use google.com/search?q=site:neosmart.net/dl to search for your complete archive

    p.s modified because the previous comment marked as spam by SK although akismet says it was ham lol

  8. 8DaveSep. 16th, 2007 at 6:38 pm

    Thanks for this!  Decided to give it a try as I just installed eAccelerator the other night.  I'm seeing an error with the eAccelerator object-cache.php

    Fatal error: Call to undefined function eaccelerator_get() in /wp-content/object-cache.php on line 135.

    Line 135 is

    $value = eaccelerator_get($key);
  9. 9Computer GuruSep. 16th, 2007 at 7:31 pm

    Dave, can you post or email me a link to a phpinfo() page on your site? (ComputerGuru@NeoSmart.net)

    I'm using XCache on NeoSmart.net and eAccelerator on my local (testbed) server with the respective plugins and haven't come across that problem...

    I tested it with PHP 5.1.6 on Windows Server 2003 with eAccelerator 0.9.5 final.... I know neither are the latest, but I don't recall any API changes in the eAccelerator API - especially not in a 0.0.0.2 version bump to 0.9.5.2....

  10. 10DaveSep. 16th, 2007 at 7:38 pm

    Just sent you an email, thanks for following up!

  11. 11Doc WinchesterSep. 16th, 2007 at 9:09 pm

    Hey, thanks! It works great here, no complaints whatsoever.

    eAccelerator 0.9.5.2/Ubuntu 7.04/PHP 5.2/MySQL 6

    Seeing a good improvement on this heavy-hit machine.

  12. 12ernie2Sep. 18th, 2007 at 10:42 pm

    I've been using APC on my server and quite disappointed with it. Sure, it is faster than nothing, but I've been looking at the benchmarks for some of the others (particularly XCache) and am damn impressed.

    I was using the APC thingy for WP by Mark Jaquith, but I think I'm going to take this opportunity to switch to XCache and use your plugin - hope it works! :D

  13. 13GauravSep. 19th, 2007 at 9:25 am

    See I'm a newbie user of wordpress.

    I'm already using wp-cache with gzip hack enabled in it.

    I'm hosted on free web server @ 110mb.com

    Still can I install it with wp-cache already enabled

    I know this is a stupid question nut still i insist to be safe

    Which is the best one Xcache or eAccelerater ? How to decide

    Can I use eAccelerator with Wp-Cache ? Plz Help

  14. 14Computer GuruSep. 19th, 2007 at 10:18 am

    Hi Gaurav,

    It all depends on whether or not your server has eAccelerator or XCache installed. If it has both, we recommend using XCache.

  15. 15GauravSep. 19th, 2007 at 11:43 pm

    See I've not installed either eAccelerator nor Xcache on my server ( and I even don't know how to do this) but only have wordpress script installed with wp-cache plugin enabled.

    Still is there any way to get speed improvements, if i enable your Xcache plugin ( without Xcache being installed on my server) in my plugins section.

    I mean can i enable both xcache  your plugin) and wp-cache on my wordpress blog?

    Further would this be safe ?

    Thanks for advice :)

  16. 16KlarkSep. 20th, 2007 at 3:11 am

    Do these plugins work with wpmu?

  17. 17Computer GuruSep. 20th, 2007 at 8:25 am

    Yep, they most certainly should. In fact, that's the most important place to use them due to the high loads.

  18. 18Computer GuruSep. 20th, 2007 at 2:59 pm

    Gaurav, no, it doesn't work that way. You need to have these already installed on the server. You can't install them, the sysadmin has to. And the plugin doesn't work without it.

  19. 19KlarkSep. 20th, 2007 at 3:59 pm

    I get an error when I install the eaccelerator plugin. 

    Parse error: syntax error, unexpected T_IF in /path/to/wp-content/object-cache.php on line 29

     

    (This is in wpmu)

     Any ideas? thanks.  

  20. 20DaveSep. 20th, 2007 at 4:15 pm

    Ok, I'm back.  Seems that the eaccelerator_get function is disabled by default based on this ticket http://eaccelerator.net/ticket/37.  Once I get some freetime I'll go and rebuild to make sure I get the right functions. 

  21. 21Computer GuruSep. 20th, 2007 at 5:08 pm

    Klark, can you give this code a shot instead:

    http://wordpress.pastebin.com/f11d9b161

    Dave, it also checks for eaccelerator_get before activating so it shouldn't crash if that function is disabled.

  22. 22KlarkSep. 20th, 2007 at 5:18 pm

    Thanks. I tried it out, and I get the same error:

     

    Parse error: syntax error, unexpected T_STRING in /path/to/wp-content/object-cache.php on line 151

     

  23. 23Computer GuruSep. 20th, 2007 at 8:33 pm

    I'm not sure what to tell you... PHP is saying that there is a problem with the code, but there is absoloutely nothing wrong with it as far as I can see... The line it's coughing on: [sourcecode language='php']$eaccelerator_info = eaccelerator_info();[/sourcecode] I suggest double-checking the extracted/copied code and make sure nothing is getting corrupted on upload to the server...

  24. 24KlarkSep. 28th, 2007 at 2:44 am

    Thanks. Removing this code solves the problem, but I'm not sure what else it does. :)

    [sourcecode language='php'] function stats() { // Note that this is the total eAccelerator stats, not just WP but also any other apps using eAccelerator var storage // $eaccelerator_info = eaccelerator_info(); // echo "\n"; // echo "Cached Variables: {$eaccelerator_info['cachedKeys']}\n"; // echo "Cached Scripts:   {$eaccelerator_info['cachedScripts']}\n"; // echo "\n";

        if ( !empty($this-&gt;cache) )
        {
            echo "\n\r";
            print_r($this-&gt;cache);
            echo "\n\r";
        }
    }
    

    [/sourcecode]

  25. 25KlarkSep. 28th, 2007 at 2:46 am

    er, I added the comment above.

    Removing the whole function solves the problem.

  26. 26KlarkSep. 28th, 2007 at 3:24 am

    I found a problem. With this plugin enabled in wpmu, the "Site Admin" functions are disabled. That is, the Site Admin option does not show up in wp-admin. Renaming object-cache.php to something else (not ending in php) restores the Site Admin function, and presumably disables your plugin.

  27. 27Computer GuruSep. 28th, 2007 at 8:07 am

    Klark, the only thing that I can think of is that your eAccelerator install has some restrictions (password maybe?) on eaccelerator_info() that end up crashing the script. The WP Site Admin feature is making a call to the stats() function, and since you don't have it, it's crashing.

    Double-check/re-compile/re-install your eAccelerator maybe? Don't know what else to offer.

  28. 28Computer GuruOct. 29th, 2007 at 5:03 pm

    Everyone please update to the latest version: http://neosmart.net/blog/2007/xcache-and-eaccelerator-wp-plugins-updated/ http://neosmart.net/dl.php?id=12 http://neosmart.net/dl.php?id=13

    This update addresses a couple of really important stability issues for multi-threaded PHP environments (like mod_php on mpm_worker and *SAPI on IIS/Netscape) plus a couple of optimizations.

  29. 29ovidiuNov. 10th, 2007 at 4:50 pm

    can someone tell me how to verify if it really works and is loaded?

  30. 30Computer GuruNov. 10th, 2007 at 5:00 pm

    If your query count drops and your XCache/eAccelerator admin pages shows that your variable cache is being used.

  31. 31ovidiuNov. 11th, 2007 at 12:05 am

    ok, I just notived I forgot to mention I am on a debian server running eaccelerator. this info is all I get from the eaccelerator control panel and it does not say anything about variable cache:

     

    eAccelerator 0.9.5.1 control panel Information

    Caching enabled
    yes
    
    
    Optimizer enabled
    yes
    
    
    Memory usage
    99.94% (31.98MB/ 32.00MB)
    
    
    Free memory
    0.02MB
    
    
    Cached scripts
    688
    
    
    Removed scripts
    0
    
    
    Cached keys
    0
    

    although the number of queries did not drop. 

  32. 32Computer GuruNov. 11th, 2007 at 7:49 am

    Looks like variable caching is not enabled in your eAccelerator setup.

    You'll have to recompile the eAccelerator binaries with var cache support.

  33. 33ovidiuNov. 11th, 2007 at 8:25 am

    hello, I might sound a little stupid, but google did not help me find out how to compile eaccelerator with variable cache enabled and neither does their help page: http://eaccelerator.net/wiki/CompileConfiguration 

    I am using eaccelerator 0.9.5.1 - no need to upgrade to 0,9,5,2 as I do not use php5 yet.

    could you give me a little hint if you personally know how to do this? 

  34. 34ovidiuDec. 14th, 2007 at 11:00 am

    hello, its me again.

    anymore ideas about this variable cache? I can't find anything on eaccelerator and variable cache? 

  35. 35Computer GuruDec. 14th, 2007 at 11:18 am

    I really haven't a clue - I no longer use eAccelerator myself.

    Either ask in their support forums/mailing lists or install and use XCache instead.

  36. 36kamperOct. 26th, 2008 at 7:19 pm

    Looks like variable caching is not enabled in your eAccelerator setup.

    You'll have to recompile the eAccelerator binaries with var cache support.

  37. 37ovidiuOct. 27th, 2008 at 6:25 am

    very funny Kamper, did you read my comments? I was saying I can't find any material on how to compile eaccelerator with variable cache enabled, neither on their site, nor with google, so if yo uhave any info for me please let me know.

  38. 38HungJan. 10th, 2009 at 6:31 pm

    I have compiled xcache with those options ./configure --enable-xcache --enable-xcache-optimizer --enable-xcache-disassembler --enable-xcache-assembler

    set xcache.var_size = 16M, but from xcache admin page, there is no cache for variables. Did I do anything wrong?

  1. 1 Looking to optimize your Wordpress blog even more ? » Reaper-X .:[ ID ]:. Pingback on Sep. 17th, 2007 at 5:39 pm
  2. 1 WordPress at Top Fast Speed by Putting Objects and Variables into « My Digital Life Pingback on Oct. 4th, 2007 at 3:45 pm
  3. 1 XCache and eAccelerator WP Plugins Updated at The NeoSmart Files Pingback on Oct. 28th, 2007 at 7:46 am
  4. 1 mutex » Blog Archive » WP-Cache or eAccelerator? Pingback on Nov. 20th, 2007 at 4:39 am
  5. 1 WordPress 2.5 and the Object Cache... — The NeoSmart Files Pingback on Mar. 20th, 2008 at 7:16 pm
  6. 1 eAccelerator WordPress Object Cache | The Murmatrons Pingback on Aug. 24th, 2008 at 8:34 pm
  7. 1 XCache Object Cache Plugin for WordPress 2.5+ :: geek ramblings Pingback on Sep. 2nd, 2008 at 2:47 pm
  8. 1 XCache Object Cache Plugin for WordPress 2.5+ | Wordpress Blog NL Pingback on Sep. 2nd, 2008 at 10:23 pm
  9. 1 Wordpress APC Object-Cache modifiziert - Projekte, Wordpress Pingback on Sep. 3rd, 2008 at 4:48 am
  10. 1 WordPress plugin Recommend: xcache object cache plugin | Webabout.org Pingback on Sep. 5th, 2008 at 5:49 am
  11. 1 20 Ultimate Wordpress Plugins - Čolović Vladan Pingback on Sep. 29th, 2008 at 11:48 pm
  12. 1 Run WordPress at Top Fast Speed by Putting Objects and Variables into XCache or eAccelerator Cache Memory (Plugin) | aw-aw.com Pingback on Jan. 20th, 2009 at 6:39 am

Leave a Reply