Golang offers a tool to profile a running golang binary called pprof. It can be enabled for most Tyk products and is useful to diagnose performance issues
Enabling the profiler
Tyk Gateway
Tyk Dashboard
Add the --pprof command line parameter. Unfortunately there isn't currently an environment variable option for this
Tyk Pump
Tyk MDCB
Tyk Enterprise Developer Portal
Set PORTAL_ENABLE_HTTP_PROFILER=true
Tyk Identity Broken (TIB)
Not currently available
Gathering a profile
Once the profiler is enabled it listens of the same port as the main application is using with the exception of the Tyk gateway. In its case it listens on the port configured for TYK_GW_CONTROLAPIPORT although if this is unconfigured it is the same port as the gateway serves APIs on.
In most cases it is best to download a profile for later analysis. To do this use the wget command or similar
CPU profile
wget -O CPU-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/profile?seconds=10Allocs
wget -O alloc-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/allocs?seconds=10Block
wget -O block-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/block?seconds=10Heap
wget -O heap-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/heap?seconds=10goroutine
wget -O goroutine-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/goroutine?seconds=10mutex
wget -O mutex-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/mutex?seconds=10threadcreate
wget -O threadcreate-profile.dmp --no-check-certificate https://<server>:<port>/debug/pprof/threadcreate?seconds=10
.dmp files are gathered they can be uploaded into a zendesk ticket or decoded several ways- There is a web based decoder. Note that the hosting of this is unofficial so take care what is uploaded into it.
- There is a docker docker image that can be run to decode the
.dmpfiles
- If golang's pprof is installed locally it can be run locally like this
$ pprof -http localhost:8001 CPU_profile_2.7.23_11.40am.dmp
Comments
0 comments
Article is closed for comments.