Improvement of PHP

Source: Internet
Author: User
One of the biggest strengths of PHP is its speed. In general, PHP always has enough speed to support the dynamic nature of Web content. in many cases, you cannot even find a faster method than it. However, when you have to deal with massive visits

One of the biggest strengths of PHP is its speed. In general, PHP always has enough speed to support the dynamic nature of Web content. in many cases, you cannot even find a faster method than it. However, when you have to deal with massive visits, high-load utilization, limited bandwidth, and other factors that bring performance bottlenecks, you may ask yourself if you can do something to make your website run better. Perhaps your PHP performance and Web server response speed will be significantly improved by adding a very inconspicuous free module. This article discusses how to further improve the performance of php Usage and give users a better browsing experience. This article is divided into three aspects (code optimization, caching, and content compression) to discuss various techniques to improve the performance of PHP, and first introduce famous products in various categories.

  Code Optimization

  First, let's look at code optimization. Note: The code optimization here does not mean to write the code more elegant and beautiful, because it is already known that there is no need to continue to discuss it; in addition, if you have considered the speed title, it is very likely that you have already optimized the source code of PHP. However, some tools can actively help us with these complex tasks, such as Zend Optimizer. Zend Optimizer can be obtained free of charge from Zend Technologies, but you must approve its consent and agree that it is not released using the GPL method. Zend Optimizer obtains and optimizes the native intermediate code compiled by Zend Engine during runtime, so that the intermediate code can be executed more efficiently.

The Zend Optimizer installation method is very simple. you only need to download the pre-compiled version provided for your platform, add the following two lines of code to php. ini, and then restart the Web server:

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

The third line of code added here is optional. Disabling zend_loader seems to make Zend Optimizer faster, so it is worth adding this line of code in php. ini. Note: zend_loader can be disabled only when Zend Encoder Runtime is not applied.

  Cache

If you want to improve the performance of your ambitious PHP Usage, using cache is also a good method. There are already many Cache plans available, including Zend Cache, APC, and Afterburner Cache.

All these products belong to the cache module ". When a request for the. PHP file is presented for the first time, the intermediate PHP code is retained in the memory of the Web server, and then the "compiled" version is used to respond to subsequent requests. This method can indeed improve the performance of utilization, because it minimizes the disk access volume (the code has been read and parsed ), the code runs directly in the memory, greatly improving the server's speed of responding to requests. Of course, the cache module also monitors changes to the PHP source file and caches the page again when necessary to prevent the page from being generated by the expired PHP code. Because the cache module can significantly reduce the server load and improve the response efficiency of PHP Usage, it is very suitable for websites with large loads.

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.