* PHP Performance issues * 1. Improper use of PHP syntax * 2. Using the PHP language to do what it is not good at * 3. The service that uses the PHP language link does not give the force * 4.PHP itself does not do the thing * * PHP Performance Problem Resolution direction * 1.PHP language-level performance optimization (generation Optimization of 2.PHP peripheral problems (Linux,mysql, disk, etc.) * 3.PHP Language performance optimization (c-tier) * * Use AB pressure test (-N Request number-c concurrent number URL target to load) *./ab-n1000-c1 XXhttp://www.baidu.com* Request per second The number of requests received per second (the bigger the better) * Time per request a demand takes a while (the smaller the better) * * Time PHP test.php Test Code Execution Times * * vld-php Opc Ode View Extension * php-dvld.active=1-dvld.execute=0 test.php * * PHP code Run Process * *.php (PHP file)->scanner (scan code, analysis)->exprs (Save as Ze nd engine recognizable files)->parser (parse)->opcodes (executable file)->exec (execution)->output (output) * Multiple PHP built-in variables, constants, Functions * PHP built-in functions are also different, Use less time complexity. Example Isset () and array_key_exists () differences * Avoid using the PHP Magic function * Disable the @ ERROR suppressor, which can incur additional overhead * Reasonable use of memory, using unset () to release unused memory in a timely manner * use as little as possible Regular Expressions * Avoid doing operations within loops for ($i =0;strlen ($STR), $i + +) {} * reduce compute-intensive business (PHP language features determine that PHP is not suitable for large data operations) * Be sure to use quoted strings for key values (key) * Reduce file class operation memory < <> <>
<读写网络数据 *="" 优化网络:1.设置超时时间="" 连接超时200ms="" 读超时800ms="" 写超时500="" 2.将串行请求并行化:使用curl_multi_*()="" ,使用swoole扩展="" 压缩php接口输出:gzip="" 好处:client更快获取数据="" 坏处:额外的cpu开销="" php缓存复用="" 时间窗口重叠方法="" php旁路方案="" xhprof="" (php="" -ri=""> < span=""> <>
<读写网络数据>
The above introduces the optimization of PHP surface test questions, including performance optimization, PHP syntax, regular expression aspects of the content, I hope that the PHP tutorial interested in a friend to help.