liveBook · Manning

Latency

As explained in Troubleshooting Java: Read, debug, and optimize JVM applications

Delay in an application's operations or responses, often caused by waiting for input or output.

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

How Troubleshooting Java: Read, debug, and optimize JVM applications covers it

How deep it goes
Defines latency and explains sampling before deeper instrumentation, stopping short of detailed profiling procedures.
Examples
Uses a Java /demo endpoint that waits five seconds for an httpbin.org response.
What you can do after
Diagnose slow operations by sampling execution and identifying code or methods for closer investigation.
How it connects
Connects latency investigation to profiling, sampling, instrumentation, and execution stacks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java: Read, debug, and optimize JVM applications. The section links point to the parts of the book it draws on.