Try   HackMD

負荷の計測

pprof

pprofはGo標準のProfilingツール。
net/httpにも対応していて、良い感じのエンドポイントを立ててくれる。
そこからデータをとってきて分析する。

こんなのが見れる

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

アプリケーションにおいて支配的な関数がわかるので結構重宝する

サーバーアプリケーションの準備

標準のhttp.ListenAndServe()てきなものを使っている場合はimportするだけでおk

import _ "net/http/pprof"

ginとかechoとかの場合はそれぞれが対応するライブラリを出してくれている

計測方法

公式Docsに詳しい使い方が載っている

go tool pprof -http=":8888" http://localhost:8080/debug/pprof/profile?seconds=30

WebUIが8888で立つ。

他にも色々なエンドポイントがある

http://localhost:8080/debug/pprof/heap
http://localhost:8080/debug/pprof/block
http://localhost:8080/debug/pprof/goroutine
http://localhost:8080/debug/pprof/threadcreate
http://localhost:8080/debug/pprof/mutex

netdata

良い感じに負荷をグラフィカルに表示してくれる君

インストール

bash <(curl -Ss https://my-netdata.io/kickstart.sh) all

使い方

これをみて

リアルタイムなリソースモニタリングツールのnetdataを試してみた

ポートは19999でListenされている