Ensure the policy-server
is running with the --enable-pprof
flag. This can also be set with the KUBEWARDEN_ENABLE_PPROF=1
environment variable.
Note: the memory profiling will cause a slightly higher CPU usage. We could fix that by activating the memory profiling only after the first dump is requested. Open a GitHub issue if you think this is a good idea.
- Port-forward policy-server port (8443):
kubectl port-forward -n kubewarden service/policy-server-default 8443:8443
- Download the CPU profile using
curl
:
curl --insecure https://localhost:8443/debug/pprof/cpu -o cpu_profile.prof
- Use
pprof
to analyze the profile:
pprof -http=:8080 cpu_profile.prof
To obtain a memory profile:
- Port-forward policy-server port (8443):
kubectl port-forward -n kubewarden service/policy-server-default 8443:8443
- Download the CPU profile using
curl
:
curl --insecure https://localhost:8443/debug/pprof/heap -o heap_profile.prof
- Use
pprof
to analyze the profile:
pprof -http=:8080 heap_profile.prof
Warning: do not use the pprof
tool from the go tool
binary, it cannot handle the memory profile generated by Policy Server.