Tips: PHP optimization, buffering, and compressing the actual solution plan

Source: Internet
Author: User
This article proposes practical solutions for PHP optimization, buffering, and compression. As a popular Web programming language, the biggest advantage of PHP is speed. PHP4 is already doing very well in this aspect, and you can hardly find a script programming language that is faster than it.

This article proposes practical solutions for PHP optimization, buffering, and compression.

As a popular Web programming language, the biggest advantage of PHP is speed. PHP4 is already doing very well in this regard, and you can hardly find a script programming language that is faster than it. However, if your utilization load is high, bandwidth is relatively small, or there are other bottlenecks that affect your server performance, you might as well try some prescriptions I have prescribed for you, check whether it is a lab.

I. code optimization

When it comes to code optimization, you may think of neat and clear code, but this article does not mean this, because if you want to seek speed, you need to adjust the PHP source code accordingly. Generally, excessive comments are removed to make the code unreadable. However, this is incredible for a good programmer. Fortunately, Zend Technologies announced that the Zend optimization engine can help you achieve this. It is free now, but you must follow the Zend Optimizer's permission. This product can optimize the intermediate code generated by the engine.

The installation of this engine is relatively simple. after downloading the version of the corresponding platform, uncompress the compressed file, add two lines in the php. ini file, and restart the Web server.

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

For the Win32 platform, it should be:

Zend_optimizer.optimization_level = 15
Zend_extension_ts = 'C: \ path \ to \ ZendOptimizer. dll'
Zend_loader.enable = Off

Ah! Not wrong, right? How are three rows? The third line is optional. Because it seems that turning zend_loader off can improve the speed, it is worth putting the third line in php. ini. Note that the condition that you disable Zend encryption is not applied.

II. Buffering

If we want to further promote, we need to consider using buffering techniques. There are some optional solutions, including Zend Cache (test version), APC, Afterburner Cache, and jpCache.

All of the above are buffer modules. they store the intermediate code produced by their first request to the. php file in the memory of the Web server, and then return the "compiled" version for future requests. As this reduces disk read/write and all work in the memory, this process can significantly improve utilization performance,

There are many ready-made products. who should I choose?

Zend Cache is a good trade product. after loading those huge PHP pages for the first time, you will obviously feel the promotion speed and the server will set aside more resources. Sorry, this product is for silver, but in some cases, you should not be stingy with it.

Afterburner Cache is a product of Bware Technologies and is currently in Beta version. it seems to be the same as Zend Cashe, but it cannot achieve the same effect as Zend Cache and cannot work with Zend optimization engine, but it is free, so I use this module.

APC (Alternative PHP Cache) is another free module announced by Community Connect. it seems that it can be used in the production environment.

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.