Skip to content

Commit 1be89be

Browse files
COLDTURNIPderekbit
authored andcommitted
doc(troubleshooting): sync agent profiler usage
longhorn-11386 Signed-off-by: Raphanus Lo <[email protected]>
1 parent 6205103 commit 1be89be

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

content/docs/1.10.0/troubleshoot/troubleshooting.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,38 @@ By default, Kubernetes uses `/usr/libexec/kubernetes/kubelet-plugins/volume/exec
7676
Some vendors choose to change the directory for various reasons. For example, GKE uses `/home/kubernetes/flexvolume` instead.
7777

7878
The correct directory can be found by running `ps aux|grep kubelet` on the host and check the `--volume-plugin-dir` parameter. If there is none, the default `/usr/libexec/kubernetes/kubelet-plugins/volume/exec/` will be used.
79+
80+
## Profiling
81+
82+
### Engine, replica, and sync agent runtime
83+
84+
You can enable the `pprof` server dynamically to perform runtime profiling.
85+
To enable profiling, you can:
86+
87+
1. Shell into the instance manager pod.
88+
2. Identify the runtime process and its port using `ps`:
89+
```bash
90+
$ ps aux | more
91+
92+
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
93+
...
94+
root 1996 0.0 0.6 1990080 20996 ? Sl Jul25 0:05 /host/var/lib/longhorn/engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --volume-name vol replica /host/var/lib/longhorn/replicas/vol-3004fc59 --size 1073741824 --disableRevCounter --replica-instance-name vol-r-ec7e35e4 --snapshot-max-count 250 --snapshot-max-size 0 --sync-agent-port-count 7 --listen 0.0.0.0:10000
95+
root 2004 0.0 0.6 1695152 22708 ? Sl Jul25 0:09 /host/var/lib/longhorn/engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --volume-name vol sync-agent --listen 0.0.0.0:10002 --replica 0.0.0.0:10000 --listen-port-range 10003-10009 --replica-instance-name vol-r-ec7e35e4
96+
root 2031 0.0 0.6 1916348 23760 ? Sl Jul25 0:46 /engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --engine-instance-name vol-e-0 controller vol --frontend tgt-blockdev --disableRevCounter --size 1073741824 --current-size 0 --engine-replica-timeout 8 --file-sync-http-client-timeout 30 --snapshot-max-count 250 --snapshot-max-size 0 --replica tcp://10.42.2.7:10000 --replica tcp://10.42.0.15:10000 --replica tcp://10.42.1.7:10000 --listen 0.0.0.0:10010
97+
```
98+
3. Enable the `pprof` server for the desired runtime (for example, sync-agent):
99+
> In this example, the sync-agent process listens on port `10002`.
100+
```bash
101+
$ /host/var/lib/longhorn/engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --url http://localhost:10002 profiler enable --port 36060
102+
$ /host/var/lib/longhorn/engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --url http://localhost:10002 profiler show
103+
104+
Profiler enabled at Addr: *:36060
105+
```
106+
> The `pprof` server is now accessible at `http://localhost:36060` *inside the instance manager pod*.
107+
4. Use the `pprof` interface for runtime inspection. For more details, refer to the [official pprof documentation](https://pkg.go.dev/net/http/pprof#hdr-Usage_examples).
108+
5. Disable the profiler after completing your analysis:
109+
```bash
110+
$ /host/var/lib/longhorn/engine-binaries/longhornio-longhorn-engine-v1.10.0/longhorn --url http://localhost:10002 profiler disable
111+
112+
Profiler is disabled!
113+
```

0 commit comments

Comments
 (0)