This is an example Spring web-app which can simulate different types of slow requests. It is intended to be used for experimenting with threaddumps.
-
Start the
ThreaddumpDempApplicationusing your IDE or mvnmvn spring-boot:run
-
Trigger the scenario you want to test. Example scenario
database_readhere:curl http://localhost:8080/fakework/database_read
-
Take the thread-dump, for example using
jcmd(| lessmakes it easier to browse/search). You have 20s.jcmd no.bekk.threaddumpdemo.ThreaddumpDemoApplication Thread.print | less -
Find and inspect the relevant thread to see what the stack looks like for that particular scenario. Hint: search for packages specific for this app, e.g.
no.bekk.threaddumpdemo
Hint: Use a no-arg jcmd to list pids and classnames for running java-processes (might not work in some envs).
jstack <pid>
jcmd <pid> Thread.print
jcmd <class-name> Thread.print
# If no JDK, SIGQUIT dumps threads to System.out
kill -QUIT <pid>
# For a Kubernetes pod (Java pid is typically 1)
kubectl exec <pod-name> -- jstack 1curl http://localhost:8080/fakework/<SCENARIO>
database_read- Slow database-querytcp_connect- Tcp-connect does not complete before timeouthttp_client_get- Slow third-party webservicedb_pool_get_connection- Forced to wait for connections as pool all connections occupiedlock_contention- Forced to wait for lock held by another threadcpu_loop- Slow local loop (i.e. pure cpu)
RUNNABLE- thread is currently executing/can be executed in the jvmBLOCKED- thread is blocked indefinitely while waiting for a lock (typically synchronized)TIMED_WAITING- thread is waiting for a period of time (triggered by e.g Thread.sleep(..))WAITING- thread is waiting indefinitely for another thread to perform a certain action (i.e. Object.wait()->Object.notify, ...)