Operations 18 min read

Diagnosing Java Runtime Problems: CPU, Memory, Disk, and Network Tips

This guide walks through systematic troubleshooting of Java runtime issues—including CPU spikes, frequent garbage collection, memory leaks, disk bottlenecks, and network anomalies—by using Linux tools such as top, jstack, jstat, iostat, vmstat, and netstat, with concrete command examples and analysis steps.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Diagnosing Java Runtime Problems: CPU, Memory, Disk, and Network Tips

Network Troubleshooting

Distinguish connection timeout ( connectionTimeout) from read/write timeout ( readTimeout / writeTimeout). Keep client‑side timeouts shorter than server limits.

TCP Queue Overflow

Monitor SYN and accept queues:

netstat -s | egrep "listen|LISTEN"
ss -lnt

“overflowed” counts full accept queues; “sockets dropped” counts SYN‑queue overflow.

RST Packets

RST indicates abrupt termination. Common causes:

Port not listening – server returns RST immediately.

Application aborts – explicit close() replaced by RST via SO_LINGER.

Stale packets arriving after the connection has been closed.

Capture RST traffic:

tcpdump -i <iface> tcp -w capture.cap

TIME_WAIT and CLOSE_WAIT

Count socket states:

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
ss -ant | awk '{++S[$1]} END {for(a in S) print a, S[a]}'

Mitigate excessive TIME_WAIT with kernel parameters:

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

Reduce tcp_max_tw_buckets to limit total sockets. High CLOSE_WAIT usually means an application thread is stuck after receiving FIN; use jstack to locate the blocked I/O calls.

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.

Javaperformancetroubleshootinggcjstack
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.