> Use php's biggest advantage is a faster rate. In general, php always has enough speed to support dynamically generated web content, in many cases even faster than it can not find the essentials. However, when faced with a huge Baihou volume, high load applications, limited bandwidth, and other types of factors that bring the performance bottleneck, you need to consider how to improve the performance of php Step / essentials issued code optimization code optimization is not just clean and clear code, Instead, the code must be simplified. can not use zend optimizer to help complete these complicated human things. zend optimizer zend technologies from the website http://www.zend.com/ free of charge, but must agree to license it agreement, because it is not issued by gpl way it's very simple principle, that is measured by test breeding occurred in the middle of zend engine code, and it is optimized, resulting in higher execution rate in the use of zend optimizer, the complex php source code of the efficiency will be significantly increased suddenly, the disadvantage is the optimized code readability declined to modify the code to bring strong bitter. zend optimizer installation essentials very simple, just follow the user's platform, download pre-compiled version, the following two lines of code added to the php.ini file, restart the web server like: zend_optimizer.optimization_level = 15zend_extension = "/ path / to / zendoptimizer.so" zend_loader.enable = off exceptionally increased The third line of code is optional, because the rate of disabling zend_loader will make optimization faster. need to focus on that, not only when using the zend encoder runtime, it can be disabled zend_loader. php program using the cache if very large , then increase the rate of approach is to use the cache. cached at the moment there are already many programs to choose from, including zend cache, apc and afterburner cache. above all these types of "cache blocks" (caching modules). php files first diversion The cache blocks from the php source code to generate some intermediate code, and these intermediate code stored in the web server's memory. misappropriated these files later, you can directly use the memory in the "compiled" before the code that obviously essentials able to improve application performance, because it quest to reduce the amount of disk Baihou minimum level (the code has been read and parsed), run the code directly in memory, quest for the server to respond to the cry of the greatly increased rate. of course, also cache blocks monitors the php source file changes, will have to re-cache the page, thereby preventing the user to get from the old page is still php code generator, because the cache blocks can significantly reduce the server load and improve response efficiency php applications, so they are very suitable for use in heavily loaded sites. zend cache is zend technologies developed by commercial software. After the first run, php pages run rate will be greatly improved immediately, the server resources of leisure time more. drawback is It is not free, but cost is still high. afterburner cache is bware technologies developed free cache blocks. zend cache with essentially the same function, but to improve performance, not as zend cache. apc (alternative php cache) is a community connect the other developed a free cache blocks, the current version is 2.0.4, you can get from http://pecl.php.net/package/apc for product applications, its performance is very stable, but also to greatly improve the response to the cry of the rate impact of Web content compression rate and another site Baihou an important factor, that is download speed. The solution is to compress content for plain text content is concerned, http compression skills can be compressed to 40% of original size, thus providing more than 60% of the data transmission preaching to save Although web server cpu usage because of compression result in a slight increase, but it can save a lot for preaching delivery network io. ietf according to specifications, large Department browsers support compression using gzip content compression algorithm which means that pages can be compressed with gzip, then sent to the client browser, the browser will not in time to receive human decompression data, and then indicate the page. For users, this process is completely transparent. Similarly, the compressed content of web pages have different essentials. mod_gzip is one kind of open source, standard apache plate, also known as Internet content acceleration section. can it and apache compiled together, or as a dso use the navigation process is relatively common, it can save 40% at the mercy of traffic. mod_gzip compress not only static content, such as html, xml, but also dynamically generated, including sql, java, wml, vrml and other birth occurred in the content, real-time compression on the server side and preaching delivery, its amazing compression efficiency is generally 60% to 85% compression dynamic web content, you can also use class.gzip to 对. php files encoding, class.gzip through the php script at the beginning and end of the diversion of some of its functions to compress the content if the site needs such compression in php.ini file in auto_prepend and auto_append the misappropriation of these functions, but will take some system overhead. php4.0.4 launched 1 new means of disposing of the output buffer-ob_gzhandler, its role and class.gzip exactly the same distinction is that it can be added directly to the php.ini file, the syntax is as follows: output_handler = ob_gzhandler; This will activate the php output buffering and compression before sending content if do not want to set up here, only where it is needed only to change the default settings (no compression), as long as the need to compress the php source code in the Table of Contents , change it. htaccess file like the following syntax: php_value output_handler ob_gzhandler or php code directly in the diversion of it: ob_start ("ob_gzhandler"); output buffer effect obviously very good, and the server will not bring exceptionally system overhead. The point is to focus on netscape communicator does not support image compression, so unless you know Baihou who use internet explorer, or must prohibit compressed jpeg and gif image Other skills in programming, you can use some tips to speed up php run rate: (1) with i + = 1 instead of i = i +1, will meet c / c + + habits, the relative efficiency is even higher (2) as an internal function using php (3) can use single quotes string, try to use single quotes string single quoted strings more efficient than double-quoted string (4) traverse the array using a foreach instead of while, foreach significantly higher than the efficiency of the while loop, and does not require diversion ofresetfunctions focus on issues when using the fourth essentials to focus on the rigor of the code, security, not all programs are suitable for a fourth way of optimization. References http://www.fw8.net / wz/news/2012-1-8/190.html> (责任编辑:admin) |