Add support for pprof

This likely still needs some tuning/tweaking, but may be helpful
as we start to do more scale/performance testing of the system.
This commit is contained in:
Daniel Hiltgen 2015-08-18 14:47:06 -07:00 committed by Joao Fernandes
parent 4da58fefa9
commit 4c9b1f1131
1 changed files with 49 additions and 0 deletions

49
profiling.md Normal file
View File

@ -0,0 +1,49 @@
# Profiling Orca
If you run the Orca server with the debug flag set, not only will you get more logging output, but we enable
remote pprof access.
Links:
* http://blog.golang.org/profiling-go-programs
* https://golang.org/pkg/net/http/pprof/
# Examples
* First deploy orca with debug.
* If you're using TLS (e.g., with bootstrap install) you'll need to add the certs to the local system's trusted certs (unfortunately pprof doesn't have an "--insecure" flag)
```bash
sudo bash -c "docker run --rm -it \
--name orca-bootstrap \
-v /var/run/docker.sock:/var/run/docker.sock \
dockerorca/orca-bootstrap \
dump-certs > /usr/local/share/ca-certificates/orca.crt"
sudo update-ca-certificates
```
* Now you can point pprof at the server
```bash
ORCA=https://192.168.104.73:443
go tool pprof ${ORCA}/debug/pprof/block
web
```
That will pop up a nice SVG image on your default browser showing the accumulated blocking calls
* Other URL endpoints of interest: ("web" should produce a nice summary in each of these)
* go tool pprof ${ORCA}/debug/pprof/profile - The CPU usage
* go tool pprof ${ORCA}/debug/pprof/heap - The memory usage
* go tool pprof ${ORCA}/debug/pprof/goroutine - The goroutine usage
* curl --insecure ${ORCA}/debug/pprof/ - Display the entry points (or use your browser)
# Dropped nodes
* It looks like nodefraction can be used to include nodes that would otherwise be dropped, but the web visualization seems to ignore it
```bash
go tool pprof -nodefraction=0.00000001 ${ORCA}/debug/pprof/block
peek swarm
```