Save 10%Pay yearly on any plan. 6% half-yearly, 3% quarterly. Help centreWhatsAppTelegram TeamsOpen a ticket

How to Monitor System Performance Using htop and Other Tools

Read htop properly and know which tool answers which question on a Linux server: top, htop, vmstat, iostat, iotop, free and the load average.

3 min readBy Swati

Reviewed by the AmazingRDP technical team

Monitoring system performance with htop

When the figures say the server is too small, see our dedicated servers. See Cheap Dedicated Servers from $38.99

When a Linux server feels slow, there are only four things it can be short of: processor time, memory, disk speed or network. The tools below show which one. All of them are free and run in a terminal.

htop: the overview

sudo apt install htop
htop

On CentOS, Rocky and Fedora: sudo dnf install htop.

Reading the top of the screen

  • One bar per processor core. Green is ordinary programs, red is the kernel, and on a virtual server a further colour can show "steal": time your VPS wanted and the host gave to someone else.
  • Mem. Green is memory used by programs. Blue and yellow are buffers and cache, which Linux gives back the moment a program needs them. A nearly full bar that is mostly cache is healthy.
  • Swp. Swap in use. A little is harmless; swap that keeps growing while the server is slow means memory is short.
  • Load average. Three figures for the last 1, 5 and 15 minutes: how many tasks were running or waiting. Compare them with the number of cores. On four cores, a load of 4 is full use; 8 means tasks queue.

Keys worth knowing

KeyDoes
F6 or P / MSort by a column; by processor; by memory
F5 or tTree view: which process started which
F4 / F3Filter / search by name
uShow one user's processes
F9Send a signal: 15 asks a process to end, 9 forces it
HHide or show threads
qQuit

top: always there

top is installed on every system. Press 1 for one line per core, M to sort by memory. The line %Cpu(s) has two fields that htop makes less obvious: wa, time spent waiting for the disk, and st, steal.

vmstat: the trend

vmstat 2 10

Ten lines, one every two seconds. Watch r (tasks waiting for a core), si and so (memory moving in and out of swap; anything but zero for long is bad), and wa.

Disk: iostat and iotop

sudo apt install sysstat iotop
iostat -xz 2
sudo iotop -o

iostat shows each disk: %util near 100 with a rising await means the disk is the bottleneck. iotop -o shows which process is doing the reading and writing.

Memory in one line

free -h

Read the column available, not free. Available is what programs can still get, counting cache that would be released.

Network

sudo apt install nload
nload

Shows traffic in and out per interface. For traffic per process, nethogs does the same job.

Which tool for which question

QuestionTool
What is using the processor or memory right now?htop
Is the server swapping?vmstat 2, free -h
Is the disk the bottleneck, and who is writing?iostat -xz 2, iotop -o
How busy was it last night?sar (from sysstat, once its collection is switched on)
How full are the disks?df -h

Reading the result

  • All cores full, load above the core count: the work needs more processor, or one program has run away. htop names it.
  • Swap growing, si/so busy: not enough memory.
  • High wa, cores idle: the disk is too slow for the work.
  • High st on a VPS: the host is busy; nothing inside your server will fix it.

What to do about each is in ways to make a VPS faster; a desktop that locks up is covered in why Ubuntu freezes. When the server is simply too small for the work, see our dedicated servers.

Questions

How do I install htop?

On Ubuntu and Debian: sudo apt install htop. On Rocky, CentOS and Fedora: sudo dnf install htop.

What does load average mean?

The average number of tasks running or waiting over 1, 5 and 15 minutes. Compare it with the number of processor cores.

Why is my memory almost full in htop?

Linux uses spare memory as disk cache and releases it when programs need it. Look at "available" in free -h.

How do I see which process uses the disk?

Run sudo iotop -o.