Server 性能调优
# 1. 简介
通过 Golang Profile (opens new window),我们可以捕获 DeepFlow Server 的数据写入性能进行分析并优化。
# 2. 步骤
- 安装 deepflow-ctl 工具。
- 找到需要 Profile 分析的 DeepFlow Server Pod IP,如果 DeepFlow Server 的副本数大于1,从中挑任意一个即可:
deepflow_server_pod_ip=$(kubectl -n deepflow get pods -o wide | grep deepflow-server | awk '{print $6}')
1
- 开启 Profile 功能:
deepflow-ctl -i $deepflow_server_pod_ip ingester profiler on
1
# 3. 获取 CPU Profile
go tool pprof http://$deepflow_server_pod_ip:9526/debug/pprof/profile
1
执行命令后,默认采样时间为 30s,可通过 http://$deepflow_server_pod_ip:9526/debug/pprof/profile?seconds=60
即带上 seconds=x
参数修改 Profile 时长,Profile 结束后,可输入 svg
命令生成矢量图格式的 Profile 结果图,并复制到本地通过浏览器查看。
# 4. 获取 Memory Profile
go tool pprof http://$deepflow_server_pod_ip:9526/debug/pprof/heap
1
执行命令后,会进行实时采样,获取当前的内存快照,然后同样可输入 svg
命令生成矢量图格式的 Profile 结果图,并复制到本地通过浏览器查看。
# 5. 其他 Profile 信息
如果还想获取其他 Profile 信息,可在 Golang SourceCode (opens new window) 找到所有可供分析的类型。