0

I am new to golang. I have come across an issue in which the number of go-routines keep on increasing inside the pods. Go profiler is already configured but it's port is not exposed as NodePort. So can't access profiler from web. I woould like to know which all go-routines are running inside pod. Is there any way to get all running go-routines in pod using terminal/cmd? One more thing this behaviour of go-routine is only reproducible in prod environment. Same version of application is deployed in lower environments as well but not reproducible. Any idea to figure out what's wrong with my application will be much appreciated.


I can see a lot of go-routines are parked in runtime/gopark package. I am not sure why they are going on hold and how to figure this out. enter image description here

Pratyush
  • 41
  • 5
  • Are you looking for [How to dump goroutine stacktraces?](https://stackoverflow.com/questions/19094099/how-to-dump-goroutine-stacktraces)? The Kubernetes layer doesn't particularly know anything about Go programs running in Pods, and you might not be able to send a signal to the process, so the code instrumentation described in that question might be your best choice. – David Maze Sep 09 '22 at 11:05
  • @DavidMaze since the application is running in production. It's not possible to just add logger and write the stacktraces and the output data. If there is any way like running any command from pod terminal itself and get the stacktraces in that terminal without making any change in code and do new deployment? – Pratyush Sep 09 '22 at 11:13
  • Goroutines are a construct within the go runtime, so only the go runtime is aware of them. If you can't instrument the process in production, then wait until its idle and dump the stack. You only need to get the stack traces once to see where they are all waiting. – JimB Sep 09 '22 at 15:18

0 Answers0