Capture pprof for vCluster 0.19.x
Capturing pprof is important for identifying performance bottlenecks and optimizing resource usage, ultimately enhancing application performance. pprof, or Performance Profiling in Go, plays a crucial role in this process.
In vCluster, users occasionally encounter performance challenges due to high CPU and memory usage. In such cases, pinpointing potential bottlenecks and optimizing performance is key to ensuring smooth application operation.
Setup and capture pprof on vCluster 0.19.xβ
Enable verbose logging and pprof endpointβ
To make the logging more verbose and to enable the endpoint that serves pprof data, add the following environment variable in the Helm chart values:
syncer:
env:
- name: DEBUG
value: "true"
You must be on the kube-context of the host cluster where the vCluster is running. If you're not using the templates from the UI, you can execute the following commands from your terminal:
kubectl port-forward -n vclusternamespace pod/vclustername-0 10443:8443
This command allows accessing services running inside the virtual cluster from your local machine without exposing them publicly through the host Kubernetes clusterβs services or ingress.
If a template is not used, the values should be added directly to .spec.template.helmRelease.values
in the VirtualClusterInstance
.
Capture CPU profileβ
In the terminal from your local, execute:
curl -k "https://localhost:10443/debug/pprof/profile?second=60" > profile60.prof
This command fetches a CPU profile of the vCluster pod's processes (such as the virtual Kubernetes API server) for the past 60 seconds. You should see a profile60.prof
file created on your local system.
Capture memory profileβ
In the terminal from your local, execute:
curl -k https://localhost:10443/debug/pprof/heap -o heapprofile.prof
This command fetches a heap profile from the vCluster pod by sending a request to the /debug/pprof/heap
endpoint. You should see a heapprofile.prof
file created on your local system.
Next stepsβ
After you've captured these files, you can send them to us. This enables us to identify opportunities for optimization and enhance the performance of your application.