Thrashing: Diagnostics & Troubleshooting

Thrashing is a typical problem that can occur on a Linux server. It refers to a situation where the Kernel spends most of its time paging data to and from the disk, rather than executing applications. This is a serious performance issue as it can virtually bring your server operations to a standstill, making your applications and services unresponsive.

Causes of Thrashing

Thrashing generally occurs when the system does not have enough physical memory to run all the running processes efficiently. This can be due to running too many memory-intensive applications simultaneously or due to a memory leak in an application.

Symptoms of Thrashing

The common symptoms that indicate your Linux server is thrashing include:

  • High CPU usage
  • Slow response or applications becoming unresponsive
  • High disk activity
  • System frequently swaps space even when the system is not fully utilizing its physical memory.

Diagnosing Thrashing

The vmstat and top commands are useful tools to diagnose thrashing on a Linux server.

The vmstat command provides information about processes, memory, paging, block IO, traps, and cpu activity. A high si and so (swap in, swap out) values in vmstat output can indicate thrashing.

The top command provides a dynamic real-time view of the running system. It displays system summary information and a list of processes currently being managed by the kernel.

Here is an example of how to use vmstat:

vmstat 5

The number 5 means update every 5 seconds.

Troubleshooting Thrashing

Once you've identified that your Linux server is thrashing, there are several steps you can take to troubleshoot the issue:

  1. Identify memory consuming processes: Use the ps command to identify the memory consuming processes. You can sort the processes by memory usage using the following command:

    ps aux --sort=-%mem | head
  2. Kill the problematic process: If you identify a process that's consuming an unusually high amount of memory, and you know it's safe to stop it, use the kill command to stop the process.

  3. Check for memory leaks: If a certain application is causing the server to thrash, there might be a memory leak in that application. Debugging the application or reporting the issue to the application's vendor might be necessary.

  4. Add more physical memory: If the server is consistently running out of memory and causing thrashing, adding more physical memory (RAM) to the server might be the best solution.

Preventing Thrashing

To prevent thrashing, monitor your server's memory usage regularly and ensure that your server has enough physical memory to handle all the running applications. You can also limit the amount of swap space used by the kernel using the vm.swappiness parameter in the /etc/sysctl.conf file.


Thrashing can seriously hamper the performance of your Linux server. But by understanding what it is, why it happens, and how to diagnose and troubleshoot it, you can keep your server running smoothly. As always, prevention is better than cure, and regular monitoring and maintenance can help you avoid this issue.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA