Skip to content

Spring web-app which can simulate different types of slow requests. Intended for experimenting with threaddumps

Notifications You must be signed in to change notification settings

kagkarlsson/threaddump-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thread-dump demo application

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.

Exercise

  1. Start the ThreaddumpDempApplication using your IDE or mvn

    mvn spring-boot:run
  2. Trigger the scenario you want to test. Example scenario database_read here:

    curl http://localhost:8080/fakework/database_read
  3. Take the thread-dump, for example using jcmd (| less makes it easier to browse/search). You have 20s.

    jcmd no.bekk.threaddumpdemo.ThreaddumpDemoApplication Thread.print | less
  4. 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

Alternative ways to get a thread-dump

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 1

Scenarios

curl http://localhost:8080/fakework/<SCENARIO>
  • database_read - Slow database-query
  • tcp_connect - Tcp-connect does not complete before timeout
  • http_client_get - Slow third-party webservice
  • db_pool_get_connection - Forced to wait for connections as pool all connections occupied
  • lock_contention - Forced to wait for lock held by another thread
  • cpu_loop - Slow local loop (i.e. pure cpu)

Thread states

  • RUNNABLE - thread is currently executing/can be executed in the jvm
  • BLOCKED - 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, ...)

Resources

About

Spring web-app which can simulate different types of slow requests. Intended for experimenting with threaddumps

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages