How to Diagnose 100% CPU Spikes in Java Production Servers (Windows & Linux)
Learn step-by-step how to identify and resolve sudden 100% CPU usage in Java production servers by locating the offending process and thread on both Windows and Linux, using tools like Process Explorer, top, and jstack, with practical command examples and screenshots.
Introduction
Production servers have several Java programs, suddenly a CPU 100% alert appears; how do you locate the problem?
The article presents two answer styles and then focuses on the practical troubleshooting steps.
Body
The same three‑step procedure applies to both Windows and Linux environments, with only the commands differing.
Find the PID of the process consuming the most CPU.
Find the thread ID (TID) within that PID that consumes the most CPU.
Locate the corresponding Java thread and address the issue.
Windows version
Many government systems run on Windows Server, so the Windows workflow is described.
Find the PID
Using the Windows Task Manager (or similar) to display the PID column, the highest‑CPU process is identified as PID 10856 .
Find the thread ID
Process Explorer (v16.22) is used to inspect threads. The most CPU‑intensive thread has TID 6616 , which is 0x19d8 in hexadecimal.
Locate the Java thread
Export a process dump, open the file c:/10856.stack, and search for 0x19d8. The stack trace shows that TestFor.java line 7 is looping, pinpointing the problem.
Linux version
Find the PID
Run top -c and press P to sort by CPU usage. The process with PID 3033 uses the most CPU.
Find the thread ID
Run top -Hp 3033 to list threads of that process, sort by CPU, and identify thread PID 3034 as the highest consumer. Its hexadecimal ID is 0xbda.
Locate the Java thread
Export a stack dump with: jstack -l 3033 > ./3033.stack Then search the dump:
cat 3033.stack | grep 'bda' -C 8The output reveals the problematic Java code, completing the diagnosis.
Conclusion
Remember to actually perform the steps on a test environment to verify the fix.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
