Latency is a slower-than-expected response or operation. To investigate it, use sampling to see what code executes and where to look more closely; instrument specific code only if more detail is needed. section 7.1
A delayed endpoint
A Java app’s /demo endpoint calls an httpbin.org endpoint configured to wait five seconds. If that response time is too long, VisualVM sampling can show active threads, execution stacks, and approximate method times to help locate where the app works or waits. The example’s target is under one second. section 7.1
Figure 7.1 The app we are investigating exposes an endpoint: /demo. When you call this endpoint, you must wait for 5 seconds for the app to respond. We need to understand why it takes so long for the endpoint to respond. We know our app calls a mock endpoint from httpbin.org, which causes the delay, but we want to learn how to investigate this scenario with a profiler. This way, you’ll know how to use similar techniques for real-world situations.
See the delayed /demo request and the external endpoint used to simulate its latency. section 7.1
