Java Developer interview question

How do you diagnose Java performance problems?

Diagnose Java performance from evidence: correlate service metrics and traces, inspect GC and thread states, capture JFR or async-profiler data, fix the measured bottleneck, and rerun the same workload.

Direct answer

What a strong answer covers

How it works

Diagnosis moves from symptom to cause with evidence at each step. Service metrics and traces say which endpoints and which dependency calls are slow. Thread dumps show whether threads are blocked on a lock, waiting on a pool, or busy computing. GC logs reveal whether pauses line up with latency spikes. Java Flight Recorder or async-profiler then attribute CPU and allocation to methods under production-like load. The fix targets the measured bottleneck, and the same workload is rerun to prove the change instead of trusting a micro-benchmark.

Example

An API whose latency climbed under load had thread dumps full of threads parked on the HikariCP pool; the trace showed each request holding a connection while calling a slow third-party API. Moving the external call outside the transaction released connections early and restored throughput, with no change to the pool size that had first been suspected.

Common mistakes

  • Increasing heap or thread pool sizes as a first move instead of reading the evidence.
  • Benchmarking a method in isolation while the real bottleneck is a lock or a database.
  • Changing several things at once so nobody knows which one helped.

A useful answer structure

Answer from your own work.

Do not memorise a script: use only examples you can explain honestly in follow-up questions.

Practise this answer with MiraHint

Open the desktop workspace and rehearse a clear answer in your own words.

Download MiraHint
Java Developer interview questions