主要是學習clinic的使用,使用的官方demo
環境准備
- 安裝
npm install -g clinic
- 命令
clinic --help
Clinic - v5.0.0
Getting started
As a first step, run the clinic doctor:
clinic doctor -- node server.js
Then benchmark your server with wrk or autocannon:
wrk http://localhost:3000
autocannon http://localhost:3000
Finally shut down your server (Ctrl+C). Once the server process has shutdown
clinic doctor will analyse the collected data and detect what type of issue
you are having. Based on the issue type, it will provide a recommendation for
you.
For example, to debug I/O issues, use clinic bubbleprof:
clinic bubbleprof -- node server.js
Then benchmark your server again, just like you did with clinic doctor.
Report an issue
If you encounter any issue, feel free to send us an issue report at:
https://github.com/nearform/node-clinic/issues
When creating an issue, it will be a huge help for us if you upload your
data to the Clinic.js cloud. To do this, use clinic upload:
clinic upload 1000.clinic-doctor
Utilities
When using Clinic.js a bunch you have fill up your directory with data folders and files.
You can clean these easily using clinic clean.
More information
For information on the Clinic.js sub-commands, use the --help option:
clinic doctor --help
clinic bubbleprof --help
clinic upload --help
clinic clean --help
clinic flame --help
Flags
-h | --help Display Help
-v | --version Display Version
demo 使用
- clone 代碼
git clone https://github.com/nearform/node-clinic-doctor-examples.git
- 運行
cd node-clinic-doctor-examples
yarn
clinic doctor --autocannon [ / ] -- node ./slow-io
- 性能報表
從圖上可以看出,有io問題,同時也包含了一些推薦的一些分析方法
分析方法
- 火焰圖
clinic flame -- node ./slow-io
試壓效果
ab -n 2000 -c 20 http://localhost:3000/
說明
clinic功能上還真是比較強大,支持的分析模式也比較多,是一款很不錯的nodejs應用內性能分析工具
參考資料
https://clinicjs.org/documentation/
https://github.com/nearform/node-clinic