Php perf

2,150 views

Published on

xhprof tcp-long apache web-cache httpd php performance

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,150
On SlideShare
0
From Embeds
0
Number of Embeds
496
Actions
Shares
0
Downloads
36
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Php perf

  1. 1. <ul><li>Performance!!! Profiling + Cache </li></ul>
  2. 2. <ul><li>OS(system_call()) strace,sysstat, top,ps,/proc </li></ul><ul><li>Httpd(Apache) valgrind(callgrind),gdb, lsof </li></ul><ul><li>PHP xhprof , x-debug,APD </li></ul><ul><li>OS(tcp/ip) tcpdump,ngrep </li></ul><ul><li>CDN </li></ul><ul><li>Client(browser) firebug, httpwatch, page speed </li></ul>
  3. 3. <ul><li>Profiling </li></ul>
  4. 4. <ul><li>Where? When? </li></ul><ul><li>http://noc.wikimedia.org/cgi-bin/report.py?db=zhwiki&sort=cpu&limit=50 </li></ul>
  5. 5. <ul><li>Xhprof @facebook </li></ul><ul><li>Xhprof Provides: </li></ul><ul><li>Diff Reports </li></ul><ul><li>Flat profile & Hierarchical profile </li></ul><ul><li>Callgraph-View </li></ul><ul><li>Memory Profile </li></ul><ul><li>Include/Require Track </li></ul><ul><li>Terminology: </li></ul><ul><li>Inclusive Time </li></ul><ul><li>Exclusive Time </li></ul><ul><li>Wall Time (User Time + System Time) </li></ul><ul><li>CPU Time </li></ul>
  6. 6. <ul><li>Xhprof & Production </li></ul><ul><li>*Production Server </li></ul><ul><li>*1/10000 </li></ul><ul><li>*Special User </li></ul><ul><li>*Hash Directory (Manual) </li></ul><ul><li>*PHP5 >= PHP5.2 </li></ul>
  7. 7. <ul><li>Web Cache </li></ul>
  8. 8. <ul><li>200 </li></ul>
  9. 9. <ul><li>304 </li></ul>
  10. 10. <ul><li>Expires </li></ul>
  11. 11. <ul><li>max-age </li></ul>
  12. 12. <ul><li>Last-Modified </li></ul>
  13. 13. <ul><li>E-Tag </li></ul>
  14. 14. <ul><li>No-Cache *Cache-Control: no-cache *Pragma: no-cache </li></ul>
  15. 15. <ul><li>Cache-Control </li></ul><ul><li>*private </li></ul><ul><li>*public </li></ul><ul><li>*max-age </li></ul><ul><li>*no-cache </li></ul><ul><li>*no-store </li></ul><ul><li>*must-revalidate </li></ul>
  16. 16. <ul><li>Browser </li></ul><ul><li>*Enter 回车 </li></ul><ul><li>*Prev/Next 上一页 / 下一页 </li></ul><ul><li>*F5 刷新 </li></ul><ul><li>*Ctrl + F5 强制刷新 </li></ul><ul><li>*Open 打开新窗口 </li></ul>
  17. 17. <ul><li>Proxy !!! </li></ul><ul><li>* 无可避免… </li></ul><ul><li>*s-maxage </li></ul><ul><li>*proxy-revalidate </li></ul>
  18. 18. <ul><li>No-Cache (Drupal) </li></ul>
  19. 19. <ul><li>Cache (Drupal) </li></ul>
  20. 20. <ul><li>Static Files Cache </li></ul><ul><li>*mod_deflate 、 mod_headers </li></ul><ul><li>* 虚机主机商 </li></ul><ul><li>将多个 css 、 js 合并到一个 php 文件 </li></ul><ul><li>*http://hostname/foo?v= <? echo $v; ?> </li></ul>
  21. 21. <ul><li>Long-Polling </li></ul>
  22. 22. <ul><li>Long-Polling </li></ul><ul><li>*web push-tech </li></ul><ul><li>*pconnection??!! </li></ul><ul><li>*ajax polling VS long-polling </li></ul><ul><li>*iframe </li></ul>
  23. 23. <ul><li>Long-Polling </li></ul><ul><li>*ulimit –n <open_file_nums> </li></ul><ul><li>*ulimit –u <max_user_proccess> </li></ul><ul><li>*tcp_max_syn_backlog </li></ul><ul><li>*Apache </li></ul><ul><li>ServerLimit 、 MaxClients </li></ul><ul><li>*Free Memory & idle CPU </li></ul>
  24. 24. <ul><li>谢谢 msn:liaowq.box@gmail.com </li></ul>

×