Operations 5 min read

Why Did My Java Service Freeze? A Deep Dive into CPU Spikes, GC, and Debugging Tricks

The article recounts a production incident where a Java service’s CPU surged to 1200%, detailing how top, jstack, and jmap were used to trace the issue to a missing parameter that caused a full‑table scan, prolonged GC pauses, and ultimately a system freeze.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Why Did My Java Service Freeze? A Deep Dive into CPU Spikes, GC, and Debugging Tricks

On a quiet morning the author was alerted that the offline system could not log in, and the production environment showed CPU usage up to 1200%.

Initial investigation used commands to identify the Java threads consuming CPU:

top -H -p <pid>   # view Java threads with highest CPU
jstack <pid> > xxx.txt   # dump thread stack
jmap -heap <pid>   # inspect heap memory

Screenshot of the top output:

Further analysis of the access log revealed that a particular API endpoint was blocked for over a thousand seconds: localhost_access_log When reproducing the issue, the system froze again when opening a detail page, and CPU spiked again.

Investigation showed that the problem was not a high‑concurrency interface but a full‑table scan caused by a missing parameter in the business code, which forced the database to scan millions of rows, leading to prolonged GC pauses and CPU saturation.

Key take‑aways:

When CPU hits 100 %, capture a thread dump with jstack to locate the offending thread.

Use the access log to find unusually long‑running API calls.

Missing request parameters can trigger full‑table scans and severe performance degradation.

Even with ample memory, GC pauses can block the application for minutes.

Additional screenshots illustrate the monitoring output and GC pause:

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DebuggingJavaCPUgc
Java Backend Technology
Written by

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!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.