Accelerator to participate in the test: XCACHE,OPCACHE,HHVM
XCache Introduction
The principles and functions of the PHP accelerator (see PHP-FPM server for Lamp architecture ) are described earlier, and XCache, as one of the most widely used PHP accelerators, performs better than earlier Eaccelerator accelerators, Therefore, this time the PHP program in the implementation of the accelerator XCache on its performance impact.
Installing XCache
# InstallationTarXF xcache-3.0.3.Tar. GZCD XCache-3.0.3/usr/local/php/bin/phpize # XCache is installed as an add-on module for PHP./configure--enable-xcache--with-php-config=/usr/local/php/bin/php-Config Make&& Make Install# At the end of the installation, a line similar to the following will appear: Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/# edit php.ini, integrate PHP and xcache:# first to import the sample configuration provided by XCache PHP.inimkdir/etc/PHP.D # This is the configuration file scan directory that was configured before PHP was installedCPxcache.ini/etc/PHP.D # Xcache.ini file is in the XCache source directory. # Next Edit/etc/php.d/Xcache.ini, locate the line beginning with extension and modify it to the following line: extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so# If there are multiple extension command lines in the php.ini file, make sure that this new row is ranked first. # See if XCache has been installed successfully:/usr/local/php/bin/php-m |grep-I. XCache
Opcache Introduction
A new generation of PHP accelerators, developed by Zend, is similar to XCache, in that it buffers PHP-executed data into memory to avoid duplication of compilation, allowing direct use of buffer-compiled code to increase speed and reduce server load, but with better performance than XCache , see test results
Installing Opcache
wgethttp//pecl.php.net/get/zendopcache-7.0.2.tgzTarXzf zendopcache-7.0.2. TGZCD Zendopcache-7.0.2/usr/local/php/bin/phpize./configure--with-php-config=/usr/local/php/bin/php-Config Make Make Install# configuration file settings, can be directly at the end of the php.ini to add the following, but in the PHP configuration file scanning directory PHP.D configuration of new files Opcache.ini, easy to manage, PHP-config-scan-dir is defined when compiling and installing PHP #VI/etc/php.d/opcache.ini[opcache]zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/opcache.soopcache.memory_consumption= -# Allocated memory size, in MB, that is able to store how much precompiled PHP code opcache.interned_strings_buffer=8# interned string in memory size, unit mbopcache.max_accelerated_files=4000# Maximum number of files allowed to cache Opcache.revalidate_freq= -# How long to check the file timestamp to change the shared memory allocation in Sopcache.fast_shutdown=1# Whether to turn on the fast off queue function, 1 to turn on OPCACHE.ENABLE_CLI=1# Allow the PHP program under the cache CLI to check the module installation success:/usr/local/php/bin/php-m |grep-I. Opcache
HHVM Introduction
HipHop VM (HHVM) is a virtual machine launched by Facebook to execute PHP code, which is a PHP JIT (just-in-time) compiler with the advantage of generating fast code and instant compilation;
HHVM PHP code compiled into C + + programs to execute, execution efficiency has been significantly improved;
According to Facebook, HHVM has made significant improvements in speed, 60% faster than the PHP interpreter currently in use, while using 90% less memory
Installing HHVM
Because at present HHVM also imposes the development stage, the domestic uses in the production environment is very few, Installation of the required environment is more complex (such as CentOS6.5 under the Boost-system and Boost-filesystem version is too low), I am still in the commissioning test phase, and so forth the test results, and then the HHVM test results are posted.
Test steps
# Find another virtual machine on the httpd server (192.168. 1.110 http://192.168.1.110:8080/index.php# Note: The test takes 20 concurrency, View the acceleration effect of the XCache accelerator without affecting access; The test page uses the previous login page of the newly deployed phpMyAdmin index.php # Note: In order to better test the PHP accelerator cache features, can be tested several times, to obtain a stable value
Comparison of test results
As can be seen, PHP Accelerator for the implementation of PHP programs to accelerate significantly, combined with the number of requests per second and the load of the PHP server view:
XCache makes PHP programs execute 3-4 times more efficiently;
Opcache makes PHP programs execute 6-7 times more efficiently;
Hhvm is said to be more powerful in accelerating the PHP program, so please look forward to it!