Linux running slow with 0 swap left

javalinuxperformanceprocessswap

Our Linux server is responding very slowly. top doesn't show any excessive CPU usage. I noticed that even though there's about 5GB of free memory, the system is using all of swap with no free swap left. Could this be reason for system running slow? Is there any solution other than reducing the number of processes?

Secondly, even though there is free memory available, why is Linux swapping already? I thought swap is used only when there’s not actual memory left.

free -m
             total       used       free     shared    buffers     cached
Mem:         32045      26218       5826          0        127        123
-/+ buffers/cache:      25967       6077
Swap:        16387      16387          0

Update:

  • swapiness is at default level: 60
  • I don't think it's a numa system
  • I see a couple of java processes running with 8GB heap: -Xms8000m -Xmx8000m

Seems nuts on first look, but possibly someone had reasons for doing this. I think this is what's eating up most of swap, but I need to further investigate how the java heap affects Linux swap and memory/performance in general. Any pointers on impact of above java heap config on system performance will be really helpful.

Best Answer

How many Java processes have been initialized with the 8GB heap? Perhaps keep the maximum at 8 and lower the initial heap size. If you have the disk space, experiment with increasing the swap size as well