Can I enable both opcache and memcache?
Will it help?
I have one dedicated server hosting magento 32gb ran 12 cores
Magento1.9 – Enable Both Opcache and Memcache
cache-improvementmagento-1.9memcached
Related Solutions
Pankaj,
Contrary to popular belief, neither using APC or Memcache as cache/session backends will make a noticeable difference to single-user page load time - unless you had a disk I/O bottleneck to begin with (meaning that the memory backed cache will outperform the slow disk based cache).
If you don't have I/O issues, then enabling them won't make a difference to the actual page load time.
Where they'll come into play is in high concurrency situations, synthetic benchmarks like Siege/AB will demonstrate this very clearly, with an almost 50% increase in request/s. How this translates to real-world performance however, isn't so dramatic.
You'll know if it is working if the var/cache
directory is empty, and if using Memcache for sessions, if the var/session
directory is empty.
If you use file-backed slow_backend
, then you'll still see cache tag data created in var/cache
- but not the cache data itself.
Bottom line, if you are trying to improve page-load time performance, changing the cache store isn't going to make a noticeable difference unless your server's HDDs are so contrained that serving files from disk is a bottleneck.
TL; DR - On MageStack we use Varnish, Redis (cache), Redis (sessions) and Eaccelerator/Zend OPCache (depending on PHP version)
You've already got most of it understood.
The cache backend, session store, opcode cache, full page cached and reverse proxy cache are all completely different.
You can use different technologies for all and you can use them ALL simultaneously (including Varnish and a FPC)
Cache Backends
- Files (Core) Default
- Memcache (Core)
- APC (Core)
- Redis (<1.9 module courtesy Colin Mollenhour)
- MongoDB (module courtesy Colin Mollenhour)
- Rubic (module courtesy Daniel Sloof)
You can only use one cache backend.
Contrary to popular belief, using a memory based cache will not improve performance. But it will overcome some fatal flaws in Magento's default file based caching.
As of writing this message, Redis is my recommendation.
Session Stores
- Files (Core) Default
- Memcache (Core)
- Redis (<1.9 module courtesy Colin Mollenhour)
- MongoDB (module courtesy Colin Mollenhour)
You can only use one session store.
Contrary to popular belief, using a memory based session store will not improve performance.
As of writing this message, Redis is my recommendation.
OpCode Cache
- APC
- XCache
- Eaccelerator (PHP <5.4)
- Zend OPCache (PHP >5.4)
You can actually install multiple opcode caches, but it's not recommended, nor would I expect to see any gains.
My recommendations are in the brackets above.
No module is required to be installed to leverage this.
Reverse Proxy Cache
- Varnish
- Nginx
- Apache
- … and many more
You can use multiple reverse proxies, and whilst doing so is complex and prone to cache elongation, it can have merits (ie. To prevent stampeding during a cache flush).
Use one when necessary (ie. Not to speed up a slow site, but to reduce resource usage on a fast site).
To leverage a reverse proxy, it needs both enabling server side and needs a module for Magento.
The reason for the module is to help control caching logic (ie. To tell the cache what it should and shouldn't cache) and also to manage cache contents (ie. To trigger purges of the cache).
I don't recommend any unless you have a total understanding of what you are doing. Badly set up reverse proxies can break header information, can cause session loss, session sharing, stale content, apply additional limits to load time/buffers, consume additional resources etc.
Full Page Cache
- EE FPC
- … lots of others (via modules)
Use one when necessary (ie. Not to speed up a slow site, but to reduce resource usage on a fast site).
Contrary to popular belief, you can (and should) use a FPC in conjunction with a reverse proxy cache. The two solve different problems and have different capabilities.
FPCs can leverage more intelligence, because they have direct access to the users session and Magento's core, whereas a reverse proxy is not application aware (it's fairly dumb in the way it works) - so the two complement each other, not compete with each other.
Ie. Don't think Varnish or FPC, think Varnish and FPC.
Best Answer
As long as you are confident you will have sufficient memory available for both then yes there isn't any reason why you can't run both - they do completely different things. Memcached (note not memcache - memcached is newer and faster option) is key value store - so you are able to store a value to a key you define for later recall, and opcache is an opcode cache which pre compiles PHP scripts for faster operation when they are requested.
If you are actually talking about opcache which comes by default with PHP 5.5, then you should only be using this from CE 1.9.1 (soon to be released at the time of writing) and EE 1.14.1 (already released) both of which add support for PHP 5.5 and so make use of the extra performance of this PHP version. If you are using an earlier version then you can use APC instead which is another opcode cache and has the advantage of having a user key value store as well - opcache does not include this. For this reason, APC will probably continue to exist after opcache is established just with the user key value functionality. To confirm however, don't use the opcode cache functionality of both APC and opcache together - pick one or the other.