promote PHP implementation speed of the full introduction (ON)

Source: Internet
Author: User
Tags apc ini php file php source code access zend
Introduction | speed | One of the advantages of doing PHP is that it is fast, and for general Web applications, it's enough to say. However, if the site's access is high, with narrow or other factors causing the server performance bottlenecks, you may have to think of other ways to further improve PHP speed. This article will explain how to do this in several ways, making it more "cool" for users to browse.

Code optimization


I don't want to tell you again how to write cleaner code here, I think everyone knows that when you need speed, you may have done a lot of work on the optimization of PHP's source code, and here's the point that this tedious work can be done by other tools. This is Zend Optimizer, which can be obtained free of charge from the Zend Technologies website (http://www.zend.com/). The principle is simple, by detecting the intermediate code generated by the Zend engine, and optimizing it to achieve higher execution speed. I think that optimizing code is a rather cumbersome task, and optimized code may become difficult to understand, especially when you put down the PHP program for a period of time, suddenly customers ask you to make some changes, you may not understand yourself; So I suggest that you do this optimization work with Zend Optimizer when the source code in PHP is more complex, and the advantage is that it doesn't make your coding complex and difficult to understand.

Installation of Zend Optimizer is very simple. Just follow the platform you use, download the relevant precompiled library, and add two lines to your php.ini, restart your Web server!

zend_optimizer.optimization_level=15zend_extension= "/path/to/zendoptimizer.so" zend_loader.enable=Off

You may be a little strange, not to say two lines, how to become three lines. But the third line is optional, and it seems that banning the zend_loader will make the optimization faster, so add the line to your php.ini file. Note that Zend_loader can be banned only if you do not use the Zend Encoder Runtime, the Zend Encoder Runtime, which is also mentioned below.

Will it be faster? Use cache (buffer)

If your PHP application still needs to be faster, the next option is to buffer. There are several different ways to achieve this. I tried my own Zend cache (evaluation version), APC and Afterburner cache.

All of the above mentioned are "buffer modules". They are similar in principle, when the PHP file is first requested, by storing the intermediate code of your PHP source code in the Web server's memory, for the same request in the future, directly provide the "compiled" version in memory. Because it minimizes access to the disk, this approach does greatly improve PHP performance. More conveniently, when your PHP source code is modified, the buffered module can detect these changes and reload them, so you don't have to worry about the client getting the old version of the program. These buffer modules are really good, but which one should I choose? Here are the following:

Zend Cache is a commercially available product for Zend Technologies (it is also a company that provides us with PHP engines and Zend optimizer for free). It's really good. After the first run, you can obviously see the speed of PHP has been greatly improved, the server has more free resources. The disadvantage is that you have to pay to buy it, but in terms of cost-effective, it is still very worthwhile.

Afterburner Cache is a free buffer module provided by Bware Technologies (bwcache.bware.it). Currently only beta, it does work looks similar to the Zend cache, but the performance of the improvement is not as Zend cache, and the existing version can not work with Zend Optimizer, but it is free.

APC (Alternative PHP Cache) is another free module provided by Community Connect (apc.communityconnect.com). Its work is very stable, speed also has a lot of improvement, it should be noted that I have not found an official test data, these are only in my application for testing, so can not be the next conclusion.

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.