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 eAccelerator for WordPress
< ?php include("http://neosmart.net/includes/chipin.php?type=wide"); ?>
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)
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 π
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 π
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?
Ah .. i mean a special page dedicated for this plugin, for example like http://neosmart.net/blog/wordpress-xcache π
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).
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
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
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….
Just sent you an email, thanks for following up!
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.
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! π
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
Hi Gaurav,
It all depends on whether or not your server has eAccelerator or XCache installed. If it has both, we recommend using XCache.
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 π
Do these plugins work with wpmu?
Yep, they most certainly should. In fact, that’s the most important place to use them due to the high loads.
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.
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.
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.
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.
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
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…
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->cache) )
{
echo “\n\r”;
print_r($this->cache);
echo “\n\r”;
}
}
[/sourcecode]
er, I added the comment above.
Removing the whole function solves the problem.
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.
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.
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.
can someone tell me how to verify if it really works and is loaded?
If your query count drops and your XCache/eAccelerator admin pages shows that your variable cache is being used.
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.
Looks like variable caching is not enabled in your eAccelerator setup.
You’ll have to recompile the eAccelerator binaries with var cache support.
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?
hello, its me again.
anymore ideas about this variable cache? I can’t find anything on eaccelerator and variable cache?
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.
Looks like variable caching is not enabled in your eAccelerator setup.
You’ll have to recompile the eAccelerator binaries with var cache support.
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.
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?