TiDB 社区创作集

FlameGraph 火焰图快速指南(TiDB)

2019-10-12  本文已影响0人  Kassadar

FlameGraph 火焰图快速指南(TiDB)

方法1:先生成 profile 文件,再使用工具解析

先生成 profile 文件

生成 profile 文件

用浏览器访问 http://{TiDBIP}:10080/debug/zip
或者
curl http://{TiDBIP}:10080/debug/zip --output tidb_debug.zip

生成的 tidb_debug.zip 包括。

goroutine               
heap(内存)                    
mutex                   
profile(CPU)                 
config                  
version  

如果只想要 cpu 的火焰图,可以使用

http://{TiDBIP}:10080/debug/pprof/profile

默认是采样10秒,如果需要修改采样时间,可以使用 ?seconds=

http://{TiDBIP}:10080/debug/zip?seconds=60

到此已经可以将 tidb_debug.zip 包提供给 PingCAP 进行分析。

安装火焰图相关组件

安装 epel-release

yum isntall -y epel-release

安装 golang

yum install -y golang

安装 Graphviz

yum install -y graphviz

使用 pprof 解析并图像化 profile/heap

go tool pprof -http 172.16.4.51:8080 .../profile

Serving web UI on http://172.16.4.51:8080
http://172.16.4.51:8080

其中 172.16.4.51:8080 为 go tool pprof 服务侦听地址

访问服务地址,在 view 中选择 flame graph











方法2:直接使用工具解析,访问 Tidb 的 Http Api

安装火焰图相关组件

安装 epel-release

yum isntall -y epel-release

安装 golang

yum install -y golang

安装 Graphviz

yum install -y graphviz

使用 pprof 解析并图像化 profile/heap,直接访问 Tidb 的 Http Api

go tool pprof -http 172.16.4.51:8080 http://{tidbip}:10080/debug/pprof/profile

Fetching profile over HTTP from http://{tidbip}:10080/debug/pprof/profile
Saved profile in /root/pprof/pprof.tidb-server.samples.cpu.001.pb.gz
http://172.16.4.51:8080

访问应用地址即可

上一篇 下一篇

猜你喜欢

热点阅读