Optimizer + is a closed-source PHP optimization acceleration component developed by Zend but available for free. it is the first and fastest opcode cache tool. Zend technology is now making Optimizer + ZendOpcache open-source under PHPLicense & nbsp. ZendOPcache cache and optimization through opcode
Optimizer + is a closed-source PHP optimization acceleration component developed by Zend but available for free. it is the first and fastest opcode cache tool. Now Zend technology company will Optimizer + in PHP License? Zend Opcache.
Zend OPcache provides faster PHP execution process through opcode caching and optimization. It stores pre-compiled script files in the shared memory for future use, thus avoiding the time consumption of reading code from the disk and compiling. At the same time, it also applies some code optimization modes to make code execution faster.
1. what is opcode cache?
After analyzing the script Code, the interpreter generates intermediate Code that can be run directly, also known as the Operate Code (opcode ). Opcode cache is designed to avoid repeated compilation and reduce CPU and memory overhead. If the performance bottleneck of dynamic content does not lie in CPU and memory, but in I/O operations, such as disk I/O overhead caused by database queries, the performance improvement of opcode cache is very limited. However, since opcode cache can reduce CPU and memory overhead, it is always a good thing-in line with the environmental attitude, should we minimize the consumption?
The modern opcode cache (Optimizer +, APC2.0 +, and others) uses shared memory for storage and can directly execute files from it, instead of "deserialization" code before execution. This will lead to significant performance acceleration, which usually reduces the overall server memory consumption and has few disadvantages.
2. Advantages and disadvantages of Optimizer + and APC
Optimizer + was renamed Opcache in middle March 2013.
According to the discussion on PHP wiki, Zend Opcache will be integrated into php 5.5. As? APC? Competitors, the new Zend Opcache is likely to replace APC, although OptimizerPlus does not have the user cache function like APC.
Advantages of OPTIMIZER + relative APC
- Performance. According to tests, Zend Optimizer + is always better than APC. The number of requests processed per second increases by 5 to 5 depending on the code ~ 20%. WordPress 2.1.1 (I don't know why I don't need a new version of WP for testing) in the test results recorded on Google doc, and the performance is improved by about 8%. Theoretically, for WP 3.5.1, the performance should also be approximately 5 ~ 10% improvement. For servers running WordPress, using Optimizer + can significantly reduce CPU usage and increase the page loading speed (graphics here ).
- Support new? PHP? Version. Both Zend and the PHP community will help Optimizer + support the latest version of PHP.
- Reliability. Optimizer + has the optional damage detection capability to prevent server crashes caused by data corruption.
- Better compatibility. The PHP community intends to make Optimizer + compatible with all PHP versions supported by the community.
Advantages of APC over OPTIMIZER +
- APC has a data cache API, but Optimizer + does not.
- APC can reclaim the memory occupied by old invalid scripts. APC has a memory manager that can recycle memory associated with scripts that are no longer in use. Unlike Optimizer +, it marks such memory as "dirty", but does not recycle them. Once the percentage of the configured threshold value for "dirty" memory usage reaches a certain value, Optimizer + restarts itself. This behavior has both advantages and disadvantages in terms of stability.
3. use Zend Opcode
Now you can use Zend Opcache to replace APC as a PHP optimization acceleration tool. The current Zend Opcode is compatible with PHP 5.2. *, 5.3. *, 5.4. * and PHP-5.5 development edition. However, the support for PHP 5.2 will be canceled in the future.
Note:: Zend Opcache? And? EAccelerator? Conflict. To install Zend Opcache, you may need to uninstall eAccelerator first-if you use this acceleration module.
Install and configure from source code
The source code of Zend Opcache is hosted in? On github, is it still called? ZendOptimizerPlus.
For installation steps, refer to this article: The new generation of PHP acceleration plug-in Zend Opcache.
Note:
- It is best to deploy it on your own server after testing in the local virtual machine;
- You are advised to delete components such as eAcceleratro, XCache, and APC before installation.
4. experience
PHP has many opcode cache components, such as APC, eAccelerator, and XCache. (For more information, see? PHP aAcelerators list .) According to the meaning on the PHP wiki, the performance of the newly introduced Zend Opcache should be the best. No matter which component is used, it is always good to use one.
For small servers, it seems that the performance differences between these components are not very obvious. My idea is that since I use it, I 'd like to use the best one. However, if you are using another opcode cache, such as one of the above mentioned, you do not need to change it immediately in terms of performance improvement.
For this site, the homepage generation time is about 0.9 s When PHP is used only, about 0.63 s when eAccelerator is used, and about 0.55 s after Zend Opcache is used. The test is very simple. open it several times to check the page generation time provided by WP Super Cache and estimate an average.
Log on to the system and check the memory usage of the Apache process. In the past, a process was able to occupy more than 40 MB of memory in a short time. now it is basically no more than 40 MB. I just don't know whether it is the credit of php 5.4 or Zend Opcache.