PHP ~ Performance comparison with various acceleration tools ~

Source: Internet
Author: User
Tags hhvm zts
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

Copy Code
# installation
Tar XF xcache-3.0.3.tar.gz
CD 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 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, import the sample configuration provided by XCache into the php.ini
MKDIR/ETC/PHP.D # This is the configuration file scan directory that was configured before PHP was installed
The CP XCACHE.INI/ETC/PHP.D # Xcache.ini file is in the XCache source directory.
# Next Edit/etc/php.d/xcache.ini, find 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 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
Copy Code


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



Copy Code
wget http://pecl.php.net/get/zendopcache-7.0.2.tgz
Tar xzf zendopcache-7.0.2.tgz
CD 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 compiled when installing PHP defined
# Vi/etc/php.d/opcache.ini
[Opcache]
Zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/opcache.so
OPCACHE.MEMORY_CONSUMPTION=128 # Allocated memory size, in megabytes (MB), that is, how much precompiled PHP code can be stored
Opcache.interned_strings_buffer=8 # interned string for memory size, in megabytes
opcache.max_accelerated_files=4000 # Maximum number of files allowed to cache
OPCACHE.REVALIDATE_FREQ=60 # How long to check file timestamps to change shared memory allocations in S
Opcache.fast_shutdown=1 # Whether to turn on the fast off queue function, 1 to turn on
Opcache.enable_cli=1 # allows PHP programs to be cached under the CLI
#检查模块安装成功:/usr/local/php/bin/php-m |grep-i Opcache
Copy Code
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 and stress test the httpd server (192.168.1.110)
# test Tool using Apache's own benchmark tool AB
# The test method is as follows:
Ab-c 20-n http://192.168.1.110:8080/index.php
# Note: The test takes 20 concurrency and, without affecting access, looks at the acceleration effect of the XCache accelerator; The test page uses the login page of the previous phpmyadmin that you just deployed index.php
# Note: In order to better test the PHP accelerator cache features, you can test a few times in a row, get a stable value
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.