So for a while now all PHP based applications at work were performing quite sloppy. Even though we’re using XCache as the opcode cache there was no difference in performance when XCache was enabled or disabled. Now, for small applications it didn’t really matter, but Zend Framework based applications were really slow. Even when all it did was route to an action and serve a page. Peak memory usage nearly topped 12 megabytes and average response time was between 600 to 950 ms. That’s a lot!
I’m sure it wasn’t the server, which has a quad-core CPU, enough free RAM and a high speed connection to the internet. Average load time is around 0.08 or so. And this is a server hosting several webshops, CRM software and CMS based websites.
Turned out that after I changed xcache.size from 16M to 64M and xcache.count from nothing to 4 (quad-core!) performance increased by almost 50%! A big Zend Framework based application went from 12 megabytes peak memory usage to only about 3.5 (depending on the type of page and actions of course). Response time went down to about 250 to 400 ms. Which is a very big increase. 400 ms Is still too much to my taste, but this is mostly for pages that fetch quite a lot of data, combine multiple views and so on. The smaller stuff (read non-ZF backed apps) how has a response time of about 80 to 180 ms, again depending on the type of page.
So remember, if you use XCache make sure you check your settings!
Update: After running for a day I found out performance degraded again. Once again it appeared that the opcode wasn’t used again. I’ve now set the xcache.ttl and xcache.gc_interval to one hour and 15 minutes respectively. Hoping this will solve the problems.
Update 2: Running multiple websites means caching a lot of files. I’ve now increased the cache size to 192, changed the gc_interval to 5 minutes and the ttl has been changed to 15 minutes. Do check though you’ve got the memory available for the increased cache size.
Why not use APC instead? APC is very active developed and maintained. It will be included into PHP core in PHP 5.4.
I used XCache several times in past. It got PHP+Apache 2.2 crashed very frequently under very high traffic. Not sure why. I switched to APC recently and everything is OK now
pcdinh
Because our the current distribution at work (Ubuntu 8.04) doesn’t have it in its package repositories. APC is, however, available in Ubuntu 10.04 but we won’t be upgrading to it any time soon.
I know it’s possible to compile APC yourself but we need system updates and upgrades to be as seamless as possible.
On my current blog I also use XCache which so far is running fine, but that’s just a single website. But I might try APC some time later. Haven’t read much about it yet though.
I don’t see why would solve the current problem (suboptimal configuration) changing the opcode cache from xcache to APC.
Tyrael
True. So far changing the settings I mentioned solved my problem.