High CPU Troubleshooting Interview Questions and Answers
Master High CPU Troubleshooting with production-ready interview questions covering CPU spikes, thread dumps, Java Flight Recorder (JFR), async-profiler, infinite loops, thread contention, JVM diagnostics, and enterprise production scenarios.
High CPU Troubleshooting Interview Questions & Answers
Introduction
One of the most common production incidents in enterprise Java applications is High CPU Usage.
Symptoms include:
- APIs responding slowly
- Request timeouts
- High application latency
- Kubernetes/OCP pods restarting
- Increased cloud infrastructure costs
- Poor customer experience
High CPU does not always mean the JVM is the problem.
The root cause could be:
- Inefficient code
- Infinite loops
- Lock contention
- Excessive Garbage Collection
- Database retries
- Logging
- Serialization
- External service retries
As a Senior Java Developer, your job is not to guess the cause, but to identify it using evidence.
1. What is High CPU Usage?
Answer
High CPU usage occurs when an application continuously consumes a large percentage of available processor resources.
Example
CPU
100%
██████████████████████
Application Slow
High CPU usually results in:
- Increased response time
- Lower throughput
- Thread scheduling delays
- Poor scalability
2. What are common symptoms of High CPU?
Answer
Typical symptoms include:
- API response time increases
- Requests timeout
- CPU reaches 90–100%
- Pods restart frequently
- High system load average
- Slow batch processing
- Thread pool saturation
Monitoring tools often detect these symptoms before users report them.
3. What are common causes of High CPU?
Answer
Common causes include:
- Infinite loops
- Inefficient algorithms
- Excessive object creation
- Frequent Garbage Collection
- Lock contention
- Busy waiting
- Heavy JSON/XML serialization
- Regular expression misuse
- Excessive logging
- Database retry loops
Always verify the cause using profiling.
4. How do you troubleshoot High CPU?
Answer
A structured approach is essential.
CPU Alert
↓
Check Monitoring
↓
Identify JVM Process
↓
Capture Thread Dumps
↓
Capture JFR
↓
Analyze Hotspots
↓
Fix Root Cause
↓
Validate
Never restart the application before collecting evidence unless required for service recovery.
5. Which Linux commands help investigate High CPU?
Answer
Useful commands include:
Identify CPU usage
top
Per-process CPU
ps -ef
Find Java PID
jps -l
Per-thread CPU
top -H -p <PID>
Thread information
jstack <PID>
JVM diagnostics
jcmd <PID> VM.info
These commands provide the initial evidence before deeper analysis.
6. Why do we capture Thread Dumps?
Answer
Thread Dumps show what every JVM thread is doing.
They help identify:
- Busy threads
- Deadlocks
- Lock contention
- Infinite loops
- Blocked threads
- Waiting threads
Example
Thread A
RUNNABLE
High CPU
----------------
Thread B
BLOCKED
Capture multiple Thread Dumps several seconds apart to observe thread activity over time.
7. Why do we use Java Flight Recorder (JFR)?
Answer
JFR records JVM runtime events with very low overhead.
It captures:
- CPU hotspots
- Method execution
- Thread activity
- GC activity
- Allocation rates
- Exceptions
- I/O
Workflow
Application
↓
JFR Recording
↓
JDK Mission Control
↓
Root Cause
JFR is safe for production environments.
8. How do you identify the thread consuming CPU?
Answer
Steps
top -H
↓
Thread ID
↓
Convert Decimal
↓
Hexadecimal
↓
Match Thread Dump
↓
Analyze Stack Trace
The stack trace reveals the code currently executing.
Example
Thread
↓
calculateReport()
↓
Nested Loop
↓
High CPU
This technique is widely used during production incidents.
9. What if CPU is high but Garbage Collection is normal?
Answer
If GC metrics are healthy, investigate other areas.
Possible causes
- Infinite loops
- Expensive algorithms
- Serialization
- Encryption
- Compression
- Lock contention
- Large data processing
- Third-party libraries
Avoid assuming every CPU problem is GC-related.
10. What if CPU spikes immediately after deployment?
Answer
Investigation steps
- Compare new release with previous version.
- Review recent code changes.
- Analyze JFR.
- Compare application metrics.
- Check logs.
- Review deployment configuration.
- Roll back if necessary.
Many production CPU incidents are introduced by recent code changes.
11. Explain a production use case.
Answer
Scenario
A Spring Boot payment service running on OpenShift suddenly reached 100% CPU.
Symptoms
CPU
100%
↓
API Timeout
↓
Customer Complaints
Investigation
Grafana
↓
top -H
↓
jstack
↓
JFR
↓
JMC
Findings
A newly introduced report generation method repeatedly serialized the same object graph inside a nested loop.
Solution
- Cached repeated calculations.
- Moved serialization outside the loop.
- Reduced object creation.
Result
- CPU reduced from 100% to 35%.
- API latency improved from 6 seconds to 400 ms.
- Throughput increased significantly.
12. What are common troubleshooting mistakes?
Answer
Common mistakes include:
Restarting the JVM immediately.
Collecting only one Thread Dump.
Ignoring monitoring dashboards.
Assuming GC is always the cause.
Ignoring database metrics.
Skipping JFR collection.
Changing multiple JVM parameters simultaneously.
Evidence should always drive troubleshooting.
13. What are the best practices?
Answer
Recommended practices
- Capture evidence before restarting.
- Collect multiple Thread Dumps.
- Record JFR during incidents.
- Monitor CPU continuously.
- Correlate logs, metrics, and traces.
- Optimize algorithms before tuning JVM parameters.
- Review recent deployments.
- Validate fixes after deployment.
- Document incident findings.
- Conduct post-incident reviews.
14. Which enterprise tools are commonly used?
Answer
Common tools include:
| Tool | Purpose |
|---|---|
| top | CPU monitoring |
| top -H | Per-thread CPU |
| ps | Process analysis |
| jps | JVM process discovery |
| jstack | Thread Dumps |
| jcmd | JVM diagnostics |
| Java Flight Recorder (JFR) | Runtime profiling |
| JDK Mission Control (JMC) | JFR analysis |
| async-profiler | CPU hotspot analysis |
| VisualVM | JVM monitoring |
| Grafana | Dashboards |
| Prometheus | Metrics |
| Datadog | APM |
| Dynatrace | Enterprise monitoring |
15. What interview tips should you remember?
Answer
Interviewers commonly ask:
- High CPU troubleshooting steps
- Linux commands
- Thread Dumps
- JFR
- CPU hotspots
- Infinite loops
- Lock contention
- Production incidents
- Monitoring tools
- Enterprise examples
Remember
- Never guess the root cause.
- Capture evidence before restarting.
- Use
top -Hto identify busy threads. - Match thread IDs with Thread Dumps.
- Use JFR to identify CPU hotspots.
- Review recent deployments.
- Validate every optimization with measurements.
- Always explain a structured troubleshooting process.
Summary
High CPU incidents are among the most common production issues in enterprise Java applications. Effective troubleshooting requires a structured, evidence-based approach using monitoring dashboards, Linux tools, Thread Dumps, Java Flight Recorder, and profiling tools. Rather than assuming the cause, successful engineers identify the true bottleneck, implement targeted optimizations, and validate improvements after deployment.
Key Takeaways
- Understand High CPU symptoms.
- Learn common CPU bottlenecks.
- Follow a structured troubleshooting workflow.
- Use Linux commands to investigate CPU usage.
- Analyze Thread Dumps effectively.
- Use Java Flight Recorder for production profiling.
- Identify CPU hotspots using profiling tools.
- Avoid common troubleshooting mistakes.
- Follow enterprise incident-response best practices.
- Support interview answers with real production scenarios.