7. 7
Hung or Slow App
» Long GC pauses and/or high GC overhead
– Basic GC tuning
− max heap size: -Xmx
− type of collector used
− -XX:+UserSerialGC
− -XX:+UseParallelGC/-XX:+UseParallelOldGC
− -XX:+UseConcMarkSweepGC
− -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC (jdk6u14+)
– Advanced GC tuning
− young generation size: -Xmn
– Baseline, tune, measure one change at a time
» Demo: HPjmeter – garbage collection analysis (and
more…)
7
8. 8
Hung or Slow App
» Deadlock
– Take thread dump to run the JVM’s deadlock detector
» Looping Threads
– Monitor CPU times of running threads
− ThreadMXBean
− JTop plug-in for JConsole/VisualVM
– Inspect stack trace of suspicious threads
8
Source: TBD
9. 9
Slow or Hung App
» Blocked threads
– Look for blocked threads waiting on the same condition
– Identify bottleneck for resource contention
– Inspect code for incautious and/or improper synchronization
» Demo: samurai – thread dump analysis tool
» Stuck threads
– Look for runnable threads with the same stack trace across
consecutive thread dumps
– Some common causes:
− Blocking for a network call without specifying connect and/or
read timeout (default may be no timeout)
− Long execution time for calls to backend servers
9