Advanced Java and JVM· 30 min

Performance and JVM Troubleshooting

Build a practical debugging habit with thread dumps, heap analysis, profiling, metrics, and JVM diagnostic tools.

Java interview lesson
Question 12 · Not reviewed

Advanced Java · operations

Can you explain this clearly in an interview?

Use the strong answer as your reference, explain it aloud in your own words, then choose how soon you want to review it again.

Interview prompt

Performance and JVM Troubleshooting

Explain it aloud in your own words

Strong answer

Performance work starts with a reproducible workload, a measurable target, and a baseline. Use logs, metrics, thread dumps, heap information, profilers, and JVM tools to identify the bottleneck before changing code. Optimize allocation, contention, I/O, database calls, and algorithms based on evidence.

Key points

  • Latency, throughput, allocation rate, CPU, and memory are different signals.
  • A faster local benchmark can still make a production service worse.
  • Thread dumps help identify blocked, waiting, and runnable threads.
  • Fix the bottleneck with the highest user impact first.

Interviewer looks for

Explain your investigation sequence and what evidence would make you change your hypothesis.

Java example

1long started = System.nanoTime();
2service.handle(request);
3long micros = (System.nanoTime() - started) / 1_000;
4logger.info("requestMicros={}", micros);

Topic interview questions

Revise this topic like an interviewer

These questions are tied to this lesson. Read each question aloud, then compare your explanation with the strong answer.

5 questions
Q1Intermediate

What is the first step in a Java performance investigation?

Strong answer

Define the user-visible target, reproduce the workload, and capture a baseline. Without a measurable comparison, an optimization may improve a local metric while harming production behavior.

Q2Intermediate

What can a thread dump tell you?

Strong answer

It shows thread states, stack traces, locks, and often deadlock information. It helps identify blocked threads, long waits, hot call paths, thread-pool starvation, and contention.

Q3Intermediate

When would you capture a heap dump?

Strong answer

Capture one when retained memory or unexpected object growth needs to be identified. Inspect dominator trees, retained sizes, GC roots, and repeated object graphs rather than only counting allocations.

Q4Intermediate

How are latency and throughput different?

Strong answer

Latency is the time taken by an individual operation, while throughput is the amount of work completed per unit time. A system can improve throughput while making tail latency worse, so both need targets.

Q5Intermediate

Why is profiling better than guessing?

Strong answer

A profiler connects CPU, allocation, lock, and I/O costs to actual call paths under a workload. It directs effort toward the bottleneck instead of optimizing code that is not limiting the system.

How well do you know this?

Your review choice is saved locally and synced to your learner profile when signed in.