PHP Performance Tuning tip-Generate highly optimized code

Source: Internet
Author: User
Tags memcached php code php performance tuning php script zend server

PHP is a scripting language executed on the server side that has developed many of the world's best-known websites, including Yahoo and Facebook. Here are 6 PHP code, performance tuning tips.

1. Upgrade PHP to the latest version

The easiest way to improve performance is to constantly upgrade and update the PHP version.

2. Using analyzer

Web applications are extremely complex and confusing because of the slow running of the Web site. One possibility is that the PHP code itself. This parser can help you quickly identify bottlenecks in the code, improve the overall performance of the site running.

Xdebug PHP extension provides powerful features that you can use to debug or analyze your code. It facilitates developers to track the execution of scripts directly and view comprehensive data in real time. You can also import this data into the visual tool Kcachegrind.

3. Error-Checking report

PHP supports a powerful error-checking feature that allows you to check for errors in real time, from more important bugs to relatively small running tips. A total of 13 separate reporting levels are supported, and you can generate user-defined test reports based on flexible matching of these levels.

4. Using PHP's Extensions

All along, everyone is complaining about the complexity of PHP content, in recent years, developers have made corresponding efforts to remove some of the redundant features of the project. Even so, the number of available libraries and other extensions is considerable. Even some developers are starting to think about implementing their own expansion plans.

5. Using the PHP accelerator

Typically, PHP scripts are compiled and executed by the PHP engine, and are converted into machine language, also known as opcode. If the php script gets the same result over and over again, why not skip the compile process completely?

Through the PHP accelerator, you can achieve this, it caches the PHP script compiled machine code, allowing the code to execute immediately, without cumbersome compilation process.

For PHP developers, there are currently two available caching schemes, one is APC (alternative PHP cache, optional PHP caching), which is an open source accelerator that can be installed through pear. Another popular scenario is Zend Server, which not only provides opcode caching technology, but also provides caching tools for the appropriate pages.

6. Avoid high cost operations through memory caching

PHP often plays an important role in retrieval and data analysis, which can lead to performance degradation. In fact, some operations are completely unnecessary, especially to retrieve some commonly used static data from the database repeatedly. Consider the short-term use of Memcached extension to cache data. Memcached's extended cache works in conjunction with the Libmemcached library, caching data in RAM, and allowing users to define the duration of the cache, helping to ensure real-time updates of user information.

Original English: Http://www.phpbuilder.com/columns/php-performance-tips/Jason_Gilmore07122011.php3?page=1




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.