We released Docker 1.9 less than a month ago. Since then, we’ve got several reports of operations being slower than they used to be. The Docker daemon doesn’t consume lots of resources, but you might want to keep an eye on it. This post shows a few tools and techniques we use to measure and analyze metrics for the Docker daemon. Although, what you’re going to learn here can apply to any application written in Go.

One of the nice things of using Go is how well it integrates pprof into the standard library. It’s super easy to collect metrics if your application exposes an http endpoint. You can read about it in the net/http/pprof package. Docker loads the Go profiler into the api when you start the daemon in debug mode:

$ docker daemon --debug

We provide some extra debug information, besides the metrics explained in the pprof package. You can collect information about all the exported variables in the system. We use the expvar package to send that information in JSON format. You can also keep track of goroutines and heap allocations. We use some unexposed handlers for that. The code where we initialize the Docker profiler is pretty straight forward if you want to check it out.