PHP interview question optimization, php interview question _ PHP Tutorial

Source: Internet
Author: User
Tags what php
Optimization of PHP interview questions: php interview questions. PHP interview questions optimization, php interview questions * PHP performance questions * 1. incorrect PHP syntax * 2. use PHP to do what it is not good at * 3. services linked using PHP language are not powerful * 4.P PHP interview questions optimization, php interview questions
* PHP performance issue * 1. incorrect PHP syntax * 2. use PHP to do what it is not good at * 3. services linked using PHP language are not powerful * 4. what PHP itself can't do ** PHP performance problem solving direction * 1. PHP language-level performance optimization (code optimization) * 2. performance Optimization of PHP peripheral problems (linux, mysql, disk, etc.) * 3. PHP language performance optimization (layer c) ** use AB stress testing (-n requests-c concurrency url target pressure test address )*. /AB-n1000-c100 http://www.baidu.com * Request per second the number of requests received per second (the larger the better) * Time per request the time required for a Request (the smaller the better) ** Time php test. php test code execution time ** vld-PHP Opcode View extension * php-dvld. active = 1 -dvld.exe cute = 0 test. php ** PHP code running process **. php (php file)-> parse (scan code, analysis)-> Exprs (saved as a file recognizable by the zend Engine)-> Parser (resolution) -> Opcodes (executable files)-> Exec (execution)-> Output (Output results) * use PHP built-in variables and constants, function * php built-in functions are also different, with low time complexity. in this example, there is a difference between isset () and array_key_exists () * try to avoid using the PHP magic function * to disable the @ error blocker, which will produce additional overhead * use the memory properly and use unset () release unused memory in time * use as few regular expressions as possible * avoid computation in the loop ($ I = 0; strlen ($ str); $ I ++) {} * reduce computing-intensive businesses (php language features make PHP not suitable for large data operations) * be sure to use a string with quotation marks for key values * Reduce File operation memory <
 <数据库<磁盘<读写网络数据 * 优化网络:1.设置超时时间 连接超时200ms 读超时800ms 写超时500 2.将串行请求并行化:使用curl_multi_*() ,使用swoole扩展 压缩PHP接口输出:Gzip 好处:client更快获取数据 坏处:额外的cpu开销 PHP缓存复用 时间窗口重叠方法 PHP旁路方案 xhprof (php -ri xhprof)

* PHP performance issue * 1. incorrect PHP syntax * 2. use PHP to do what it is not good at * 3. services linked using PHP language are not powerful * 4. p...

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.