PHP promotion speed overview

Source: Internet
Author: User
One of the strengths of PHP is its fast speed. it is enough for general websites. However, if the site visits are high, bandwidth is narrow, or other factors cause performance bottlenecks on the server, you may have to consider other measures.

One of the strengths of PHP is its fast speed. it is enough for general websites. However, if the site visits are high, bandwidth is narrow, or other factors cause a performance bottleneck on the server, you may have to think about other measures to further speed up PHP. This article will first introduce how to achieve this in several ways, so that users can be more comfortable browsing ".

Code Optimization

I don't want to tell you how to write cleaner code again here. I want everyone to understand that when speed is needed, you may have done a lot of work on optimizing the PHP source code. here, we propose that this tedious work can be done by other tools. This is Zend Optimizer, which is available for free from Zend Technologies's website (http://www.zend.com. Its principle is very simple. it can be improved by detecting intermediate code generated by the Zend Engine and optimizing it. I think code optimization is a cumbersome task, and the optimized code may become hard to understand, especially when you put down the PHP program for a while, suddenly, when the customer asks you to make some corrections, you may not understand it yourself ;-). Therefore, I suggest you use Zend Optimizer to optimize PHP when the source code is complex. the benefit is that it will not make your code complex and difficult to understand.

Installing Zend Optimizer is very simple. Download the relevant pre-compiled library based on your application platform, and add two lines in your php. ini to restart your web server!

Zend_optimizer.optimization_level = 15
Zend_extension = '/path/to/ZendOptimizer. so'
Zend_loader.enable = Off

Maybe you are a little surprised. isn't it just two rows? how is it changed to three rows. However, the third line is optional. it seems that disabling this zend_loader will speed up optimization, so you may wish to add this line to your php. ini file. Note that zend_loader can be disabled only when you do not apply Zend Encoder Runtime. Zend Encoder Runtime is also mentioned below.

Is it faster? Application cache (Buffering)

If your PHP Usage still requires a faster speed, the next step is buffering. There are several different methods to achieve this. I have tried Zend Cache (evaluation version), APC, and Afterburner Cache myself.

All of the above are "buffer modules ". They work in a few different ways. when the PHP file is first begged, you store the intermediate code of your PHP source code in the memory of the web server, are directly supplied to the "compiled" version in the memory. Since it can minimize disk visits, this method can indeed greatly improve PHP performance. More conveniently, when your PHP source code is corrected, the buffered module can detect these changes and re-load the changes, so you don't have to worry about the old version of the program. These buffer modules are really good, but which one should I choose? Let's take a look:

Zend Cache is a commercial product of Zend Technologies (it is also a free company that provides PHP engine and Zend Optimizer for us ). It is really good. After the first run, you can obviously notice that the PHP speed has been greatly improved, and there are more idle resources on the server. The problem is that you have to pay for it, but it is very worthwhile for cost effectiveness.

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.