How to optimize the performance of several PHP sites-PHP Tutorial

Source: Internet
Author: User
Tags ioncube
This article describes several PHP site performance optimization methods. If you can reasonably use 1: objectcode cache every time a request occurs, you need to re-compile your object code. if you use the cache, this avoids re-use.

1: object code cache

Every time a request occurs, you need to re-compile your object code. if you use the cache, you can avoid re-compilation, this allows you to execute scripts faster and improve the performance of PHP sites.

You can use the following packages:

A) Ioncube: the http://www.ioncube.com/

B) Zend Encoder: http://www.zend.com/products/zend_safeguard

C) Turckl MMCache: http://freshmeat.net/projects/turck-mmcache/

2: template system

The template system provides another caching method. Content cache. When you have a lot of static data and many pages do not need reload, the template system is very helpful. The cache system also separates code from html, which not only improves the code execution time, but also facilitates future maintenance and improves the PHP site performance.

A) Smarty Templates: http://smarty.PHP.net/

B) Pear Templates: http://pear.PHP.net/package/html_template_it/redirected

C) PHP savant: http://PHPsavant.com/yawiki/

3: Distributed object cache system

Memcached is the most widely used

This system puts database data in a large memory pool, which makes your website run fast and optimizes the performance of PHP sites.

4: set some PHP variables

Variables_order = 'gpc'

Register_argc_argv = 'off'

Register_globals = 'off'

Always_populate_raw_post_data = 'off'

Magic_quotes_gpc = 'off'

5: Output Compression

Almost all browsers support Gzip compression. gzip can reduce the output by 80%, and the cost is about to increase the cpu computing workload by 10%. However, what you earn is that not only does the bandwidth usage decrease, but your page loading will become fast and your PHP site performance is optimized.

You can enable it in PHP. ini.

Zlib. output_compression = On

Zlib. output_compression_level = (level) (level may be a number between 1 and 9. you can set different numbers to make it suitable for your site .)

If you use apache, you can also activate the mod_gzip module, which is highly customizable.

6: Others

When you use a database, you only need the data you need to use to avoid using sentences such as select * from mytable.

In addition, using indexes is also helpful for optimizing the performance of PHP sites.


Tip 1: When an object code cache request occurs, you need to re-compile your object code. if you use the cache, you can avoid re-compiling...

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.