Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using both Opcache and Xcache

I'm just wondering is it stupid to use both Xcache 3 with Zend Opcache at the same time to cache PHP files? I know that both do almost the same job, but not sure if that would make any difference on the performance and speed.

I want to speed up my php page load so that visitors don't need to wait long.

any thoughts on that?

like image 781
Digital site Avatar asked Jun 22 '14 18:06

Digital site


People also ask

Should I enable Opcache?

You should definitely enable opcache. I remember that WordPress has something like 8x smaller response time with opcache. Difference may be less pronounced for Laravel, but will still be huge.

How can I tell if Opcache is working?

To check if the caching engine works properly, just look at the percentages at the “Overview” tab at the opcache-gui page. If the memory usage and hit rate values are greater than zero, it means that the OpCache is caching the PHP code and the cached files are being used to handle the requests.

How does PHP Opcache improve script performance?

“OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.”

What is Opcache in WP Rocket?

OPcache is a type of caching system that saves precompiled script bytecode in a server's memory called a cache, so each time a user visits a web page, it loads faster.


1 Answers

To answer your question: Yes, you should not run xcache and Zend Opcache at the same time. If you do, you'll get undefined behaviours, most notably "cannot redeclare class XYZ" fatal errors. That happened to me after a systems upgrade, where the packet maintainer activated Zend Opcache along the already existing xcache installation.

As for the matter of which of both to use for opcaching, that depends on your specific code - I'd recommend setting up a test environment and firing up the Apache Benchmark or a similar tool to check the answer times.

On a default wordpress installation, I was able to get a speedup (uncached vs xcache) of about 5-7x, which is quite significant. If you really need more, you'll need to check out the other possibilities already mentioned in the comments like

  • using a loadbalancer and multiple application servers
  • using memcache or memcached to cache database queries and other load heavy operations
  • switching to another database system like a NoSQL system (be careful of the consequences)
  • changing your architecture to a static site with webservices providing interactive content
like image 68
Lars Avatar answered Sep 20 '22 23:09

Lars