Knowledge Base

Everything you need to know about HostZealot

How to monitor CPU and memory usage on a Linux server?

Monitoring CPU and memory usage can help you identify processes that consume excessive server resources and diagnose performance problems on your Linux server.

Linux provides several built-in tools for checking current resource usage, system load, and running processes.

Check CPU usage with top

Run the following command:

top

The top utility displays real-time information about CPU usage, memory usage, system load, and running processes.

In the CPU summary, pay particular attention to:

  • us — CPU time used by user processes.
  • sy — CPU time used by the kernel.
  • id — idle CPU time.
  • wa — time spent waiting for I/O operations.

The process list also shows the %CPU value for individual processes. A consistently high value can help identify applications consuming significant CPU resources.

Note:
On a multi-core system, a multi-threaded process may display CPU usage above 100%. For example, approximately 200% CPU usage can indicate that the process is using the equivalent of two logical CPUs.

Check the system load average

To quickly view the current load average, run:

uptime

The command displays three load average values representing approximately the last 1, 5, and 15 minutes.

Load average is not the same as CPU usage. It represents the average number of tasks that are running, waiting for CPU time, or waiting in certain uninterruptible states.

To check how many logical CPUs are available to the system, run:

nproc

When evaluating load average, compare it with the number of logical CPUs available to your server. For example, a sustained load average around 4 on a server with 4 logical CPUs indicates a much heavier relative load than the same value on a server with 16 logical CPUs.

Note:
A high load average does not always mean that the CPU itself is overloaded. Processes waiting for disk or other I/O operations can also increase the load average.

Find processes using the most CPU

You can display processes sorted by CPU usage with:

ps -eo pid,user,comm,%cpu,%mem --sort=-%cpu | head

This can help you identify which processes are consuming the most CPU resources.

Check memory usage

To view current RAM and swap usage, run:

free -h

The output shows the total, used, free, and available memory as well as swap usage.

When checking memory availability, pay particular attention to the available value. Linux uses otherwise unused RAM for filesystem cache, so a low free value alone does not necessarily indicate a memory shortage.

If the available memory remains very low and the server is actively using swap, applications may experience reduced performance. You can use top or other monitoring tools to identify processes consuming large amounts of memory.

Monitor resource usage over time

A single measurement does not always indicate a performance problem. CPU usage and system load can temporarily increase during backups, software updates, scheduled tasks, database operations, or other resource-intensive processes.

If the server frequently becomes slow or unresponsive, monitor CPU usage, load average, available memory, swap usage, and the processes consuming the most resources over a longer period.

Share
cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.