8

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?

9
  • 2
    You can only serve 1 cached file to the visitor, so creating 2 is unnecessary overhead. You need to do some performance testing between the 2 and choose one. Commented Jun 22, 2014 at 18:15
  • 1
    MEMCACHE is great if you can afford the RAM. If you can't afford the RAM, then I'd stick with file system based caching. Any way you look at it, you're going to hit the I/O on the disk. Commented Jun 22, 2014 at 18:20
  • 1
    Just because two things each make something faster than none, doesn't mean using both will make it faster still. Imagine trying to put two engines into one car: first, you've got to somehow connect them both to the wheels at the same time, and have them help each other rather than just snarling everything up. Commented Jun 22, 2014 at 18:22
  • 2
    Note that many users cache from a tmpfs in Linux which is the same as caching in RAM since tmpfs lies in RAM. RAM caching is ideal for commonly used files but many times, the file system will handle caching to RAM for you. Commented Jun 22, 2014 at 18:25
  • 2
    Opcache works well with APCu and memcache. Don't mix xcache and opcache. Also don't bother with reverse proxy caches such as squid or varnish unless you are a reasonably experienced sysadmin. You will just get hopelessly tangled in knots Commented Jun 23, 2014 at 9:59

1 Answer 1

6

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.