Can zend opcode cache and APC cache run together on same server?

Satyadeo Kumar asked:

I am on a dedicated server – running multiple portals in respective virtual directories. Some of the previously loaded websites are using Zend opcode cache. While my new commerce portal uses an APC based cache and I have migrated this website to the new server.

I am having frequent internal server 500 errors and crashes.

I am having following config:

  • PHP 5.4.27 and APC 3.1.13,
  • Centos server with about 4 GB ram,
  • APC is using php-fpm

Zend opcode cache config:

Opcode Caching  Up and Running
Optimization    Enabled
Startup OK
Shared memory model mmap
Cache hits  71322
Cache misses    1049
Used memory 13544916
Free memory 42838688
Wasted memory   10725260
Cached scripts  298
Cached keys 309
Max keys    3907

APC config:
shm_size = 2024M
..and so on…

Could this be a possible reason for crashes? Do i need to disable one of them or can they run together. I am afraid disabling zend should not cause issues to other websties – so just wanted to be sure?

My answer:

I can imagine what would happen if you tried to run two opcode caches simultaneously. It looks a lot like this.

502 Bad Gateway

So you should run one opcode cache, and one only.

And, this may surprise you, but you need to get rid of APC, and keep Zend OPcache. The reason is that APC is very, very crashy. It alone may well be the cause of your PHP crashes, as it was for me and many others.

Unless your new commerce portal is truly bizarre, it should work fine with Zend OPcache.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.