Php perf

24
Performance!!! Profiling + Cache

description

xhprof tcp-long apache web-cache httpd php performance

Transcript of Php perf

Page 1: Php perf

Performance!!!

Profiling + Cache

Page 2: Php perf

OS(system_call())strace,sysstat, top,ps,/proc

Httpd(Apache) valgrind(callgrind),gdb, lsof

PHP xhprof, x-debug,APD

OS(tcp/ip) tcpdump,ngrep

CDN Client(browser) firebug, httpwatch, page

speed

Page 3: Php perf

Profiling

Page 4: Php perf

Where? When?

http://noc.wikimedia.org/cgi-bin/report.py?db=zhwiki&sort=cpu&limit=50

Page 5: Php perf

Xhprof @facebook

Xhprof Provides: Diff Reports

Flat profile & Hierarchical profile

Callgraph-View

Memory Profile

Include/Require Track

Terminology: Inclusive Time

Exclusive Time

Wall Time (User Time + System Time)

CPU Time

Page 6: Php perf

Xhprof & Production

*Production Server

*1/10000

*Special User

*Hash Directory (Manual)

*PHP5 >= PHP5.2

Page 7: Php perf

Web Cache

Page 8: Php perf

200

Page 9: Php perf

304

Page 10: Php perf

Expires

Page 11: Php perf

max-age

Page 12: Php perf

Last-Modified

Page 13: Php perf

E-Tag

Page 14: Php perf

No-Cache*Cache-Control: no-cache*Pragma: no-cache

Page 15: Php perf

Cache-Control

*private*public*max-age*no-cache*no-store*must-revalidate

Page 16: Php perf

Browser

*Enter 回车*Prev/Next 上一页 / 下一页*F5 刷新*Ctrl + F5 强制刷新*Open 打开新窗口

Page 17: Php perf

Proxy !!!

* 无可避免…

*s-maxage

*proxy-revalidate

Page 18: Php perf

No-Cache (Drupal)

Page 19: Php perf

Cache (Drupal)

Page 20: Php perf

Static Files Cache

*mod_deflate 、 mod_headers

* 虚机主机商 将多个 css 、 js 合并到一个 php 文件*http://hostname/foo?v=<? echo $v; ?>

Page 21: Php perf

Long-Polling

Page 22: Php perf

Long-Polling

*web push-tech

*pconnection??!!

*ajax polling VS long-polling

*iframe

Page 23: Php perf

Long-Polling

*ulimit –n <open_file_nums>

*ulimit –u <max_user_proccess>

*tcp_max_syn_backlog

*Apache

ServerLimit 、 MaxClients

*Free Memory & idle CPU

Page 24: Php perf

谢谢msn:[email protected]