PHP Accelerated Operation optimization

Source: Internet
Author: User
Tags apc php session php script php web server zend

The performance of a system, in addition to the program itself to write the perfect, but also to see the PHP itself some problems, for PHP operation optimization, mainly have these accelerators: Wincache,xcache,zendopcache,eaccelerator accelerator;

Wincache: (Xee: Microsoft's website)

Wincache only to build PHP under IIS, if you run other PHP Web server under Windows Wincache is not very good, you can consider the use of Zend effect is better (php5.5 version has been integrated Zend Opache).

Everyone feels that PHP is not as good as running under Linux in Windows, so Microsoft has launched the Wincache Extension for PHP program, currently supports two versions of 1.1 and 1.3, respectively, for php5.2/5.3/5.4/ Released in version 5.5, Wincache is the software that accelerates PHP under Windows, with significant results. In some tests, Wincache scored better than Eaccelerator and XCache. Wincache can be downloaded from Microsoft's official IIS website, or it can download at the hottest software station, currently only supports fastcgi run mode, Non Thread safe version of PHP. ( reference:http://www.veryhuo.com/down/html/72353.html)

PHP official English:Windows Cache Extension for PHP are a PHP accelerator that's used to increase the speed of PHP applications Ru nning on Windows and Windows Server. Once the Windows Cache Extension for PHP are enabled and loaded by the PHP engine, PHP applications can take advantage of T He functionality without any code modifications. The extension includes PHP opcode cache, file system cache and relative path cache. In addition the extension provides cache API ' s and a PHP session handler.

(Detailed usage information Wincache Installation and Configuration Tutorial & Windows Cache Extension for PHP under Windows Server R2 64Bit : PHP quick access provider in IIS c4>)

XCache:

Xcache and memcached are two different levels of caching, and there is no comparability.
Xcache is the PHP underlying cache, which compiles the PHP program into bytecode (byte code) and executes the PHP script by installing the corresponding program on the server. Memcached is an application-level cache that improves the speed of dynamic, database-driven Web sites by caching data and objects in memory to reduce the number of times a database is read.
XCache do not need to modify the PHP program, as long as the installation can automatically accelerate your program, and memcached need you to modify the program, you need to ask the database before the operation of the memcached have no cache data, if there is no expiration will not access the database, To achieve the goal of reducing database queries.
PS: The bottleneck of LAMP is in M, the database, replacing the old relational database with the new KVDB can directly improve the performance of the Web application.

Zendopcache:

The predecessor of Zend Opcache was Zend Optimizer + (Zend o+), with PHP5.5 Zend in the release of O+, and renamed: Zend Opcache. However, the default is not enabled, you can enable in the INI file.

As you know, PHP currently has three cache plug-ins: APC, Eaccelerator, XCache, but they may all disappear in the future, because PHP 5.5 is already integrated Zend Opcache, features similar to the first three but slightly different, caching speeds are said to be faster ( Xee: Zend Opcache and APC are all PHP official and trustworthy. It won't be slow anyway, but will it be a problem with other plugins? haha).

According to statistics, Zend Opcache performance is better than APC, can increase by 5%-9%.

Zend Optimizer + accelerates php execution with opcode caching and optimizations. It improves PHP performance by storing precompiled PHP scripts in shared memory. This eliminates the process of reading PHP files from disk and compiling them. In addition, It also provides a small number of byte-code optimization patterns that make code execution faster.

Notable is the Zend Opcache support php5.2.0+ version, that is, as long as more than 5.2 of PHP, can be used Zend Opcache, and do not need to upgrade to PHP5.5, so at our current production site can try to use Zend Opcache, such as DRUPAL6, DRUPAL7-based php5.2,php5.3 and other versions.

(Refer to: http://www.cnblogs.com/keheng/articles/3721179.html & Improve PHP performance with Zend Opcache )

Eaccelerator: (Xee: The official website seems to have not maintained for a long time)

Eaccelerator cannot be compatible with php5.5.0, fortunately, PHP provides Zend Opcache by default in 5.5.0, So have been accustomed to eaccelerator friends if you want to upgrade to php5.5.0, may be temporarily and Eaccelerator said bye bye.
Configuring Zend Opcache
has always been accustomed to using eaccelerator to provide acceleration for PHP, but there are two problems:
Eaccelerator temporarily incompatible php5.5.0

Eaccelerator and Zend Opcache conflict

Fortunately, the php5.5.0 default provides Zend Opcache for PHP acceleration, the configuration method is as follows:
Zend_extension =/usr/local/webserver/php-d/php-5.5.0/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
; The path above zend_extension path is opcache.so
opcache.memory_consumption=128
Opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
Opcache.revalidate_freq=60
Opcache.fast_shutdown=1
Opcache.enable_cli=1
Note: If the opcache.so instructions are not found in your PHP extension, please reinstall

The main principles of these PHP acceleration plug-ins are the same, that is, to buffer the PHP data into memory to avoid duplication of the compilation process, the ability to directly use the buffer compiled code to improve speed, reduce server load, their efficiency is obvious, like Drupal this huge CMS, Each time you open a page to call dozens of PHP files, execute tens of thousands of lines of code, the efficiency can be imagined, after installing an APC and other accelerators, the speed of opening the page significantly faster.

For each setting, we should be careful not to be too optimized to cause some problems, but can not find the problem! This is not worth the candle!

PHP Accelerated Operation optimization

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.