| title | Profiling Karmada |
|---|
To profile Karmada components running inside a Kubernetes pod, set --enable-pprof flag to true in the yaml of Karmada components.
The default profiling address is 127.0.0.1:6060, and it can be configured via --profiling-bind-address.
The components which are compiled by the Karmada source code support the flag above, including Karmada-agent, Karmada-aggregated-apiserver, Karmada-controller-manager, Karmada-descheduler, Karmada-search, Karmada-scheduler, Karmada-scheduler-estimator, Karmada-webhook.
--enable-pprof
Enable profiling via web interface host:port/debug/pprof/.
--profiling-bind-address string
The TCP address for serving profiling(e.g. 127.0.0.1:6060, :6060). This is only applicable if profiling is enabled. (default ":6060")
You can get at the application in the pod by port forwarding with kubectl, for example:
$ kubectl -n karmada-system get pod
NAME READY STATUS RESTARTS AGE
karmada-controller-manager-7567b44b67-8kt59 1/1 Running 0 19s
...$ kubectl -n karmada-system port-forward karmada-controller-manager-7567b44b67-8kt59 6060
Forwarding from 127.0.0.1:6060 -> 6060
Forwarding from [::1]:6060 -> 6060The HTTP endpoint will now be available as a local port.
You can then generate the file for the memory profile with curl and pipe the data to a file:
curl http://localhost:6060/debug/pprof/heap > heap.pprofGenerate the file for the CPU profile with curl and pipe the data to a file (7200 seconds is two hours):
curl "http://localhost:6060/debug/pprof/profile?seconds=7200" > cpu.pprofProfiling data can be inspected using the go tool pprof command.
To view top memory consumers you can use:
go tool pprof -top heap.pprofTo view top cpu consumers you can use:
go tool pprof -top cpu.pprofYou can enter interactive mode for deeper analysis:
go tool pprof heap.pprof