Load and process control: top, htop, atop

If your site is slow, you need to check the load on your server. When a large number of processes are running, the server resources may be insufficient. At the same time, there will be delays in completing all tasks. Be sure to keep in mind that the operating system and the control panel also consume the resources of the VPS server.

To analyze the load of a VPS server running Linux, the following utilities are most often used:

top - a standard utility, installed in all Linux versions by default,

htop - easier to use than top, interactive,

atop - allows logging.


To start, just connect to your VPS server via SSH and run:


As a result, the following will be displayed:


General information about the system is displayed in the upper part of the window. Running processes are displayed below, in descending order of load. In the top utility, the output is updated every two seconds.

Up - system uptime (since the start),

User - the number of users in the system,

Load average - the average load on the server. Three values are displayed here - load 1, 5 and 15 minutes ago.

Tasks total - the total number of processes,

Tasks running - the number of running processes,

Tasks sleeping - the number of processes in standby mode,

Tasks stopped - the number of stopped processes,

Tasks zombie - the number of child processes that are waiting for the parent process to terminate.

Cpu (s) - CPU use by various types of processes in percentage, includes:

  • us - user processes,
  • sy - kernel processes,
  • ni - user processes with restrictions,
  • id - unused resources,
  • wa - input / output operations,
  • hi - hardware interrupt routines,
  • si - software interrupts,
  • st - forced wait while the hypervisor is serving another virtual processor (i.e. how much CPU time is stolen from the VPS).

The higher the id, the better. That is, the processor is not fully loaded and there is a reserve for additional tasks.

A high value of the us indicator indicates that it is necessary to optimize the site code.

Mem, Swap - RAM and swap usage:

  • total - total volume,
  • free - how much is free,
  • used - how much is used.

All processes are displayed in order of increasing processor load.

  • PID - process identifier;
  • USER - the user who started this process;
  • PR - the priority of the process;
  • NI - changed process priority (using nice command)
  • VIRT - the amount of virtual memory used by the process. For example, if a process requested 100MB and uses only 50MB, then VIRT will show 100MB.
  • RES - the amount of actually used RAM. For example, if the process requested 100MB and uses only 50MB, then RES will show 50MB.
  • SHR - the amount of memory shared with other processes (i.e. memory that can be used by other processes).
  • S - process status (running, sleeping, zombie).
  • % CPU - the percentage of processor load by the current process;
  • % MEM - the percentage of RAM used by the process;
  • TIME - the time the process has been running since the start;
  • COMMAND - the name of the process (how the command was launched).

Control in the top utility

  • Spacebar - refresh the output window
  • M - sorting by memory usage column
  • P - sorting by cpu usage column (standard sort)
  • T - sorting by the running time of processes
  • A - sorting by consumption of different resources
  • u - sorting by username (enter username)
  • k - process termination (process PID is indicated - identifier)
  • n - specifying a certain number of processes in the output, after the command, a number is entered
  • c - displays the full path of the process in the COMMAND column
  • h - help
  • q - exit the program


The htop utility is not built-in like top, it needs to be installed on the server:


apt-get install htop


yum install htop


Then run:


The utility output looks something like this:


The output of the htop utility has the same structure as top - in the upper part there is information about the system: CPU load, used RAM, average load for 1, 5 and 15 minutes. Below it is a list of processes sorted by CPU load.

Changing the sort is done as in top:

  • M - by memory
  • P - by processor
  • T - by time

Additional commands:

Spacebar - mark the process (convenient to use for performing operations on a group of processes),

u - display processes of a specific user

The function keys are used to control htop:

  • F1 - help
  • F2 - change output parameters
  • F3 - search for processes
  • F4 - process filtering (search by part of the name)
  • F5 - display process tree - parent and child
  • F6 - change sorting
  • F7 - increase priority
  • F8 - downgrade priority
  • F9 - termination of the process (you need to select the process with the mouse or keyboard, the PID of the process is entered into top)
  • F10 - exit the program

The available actions and key combinations for their execution are displayed in the lower part of the htop program window (they may vary depending on which menu you are in).


The atop utility is useful for diagnosing floating errors. It allows you to keep logs, i.e. monitor the work of processes over the past period.

The atop utility is not built-in like top, it needs to be installed on the server:


apt-get install atop -y


yum install atop -y

For more efficient use, it is recommended to add atop to startup:

Ubuntu / Debian / CentOS 7

systemctl enable atop

CentOS 6

chkconfig atop on

Ubuntu 14.04

rm /etc/init/atop.override

To run atop, enter:


The output of the atop utility looks like this:


The upper part contains general information about the system, load on the processor, core, memory and network. Processes are displayed at the bottom.

Commands for management in the atop utility:

  • m - sorting processes by memory usage
  • d - sorting processes by disk load
  • n - sorting processes by network load (available with the installed kernel patch)
  • u - display load by user
  • v - details of the process
  • i - set the output update interval (default 10 seconds)
  • g - restore default output

Shift + d, Shift + m, Shift + n - sorting the current list by the specified parameters: disk, memory, network.

Atop logs

The atop utility saves system state data every 10 minutes by default. The log file is located in the /var/log/atop directory.

The name of the log file for the day is atop_YYYYMMDD.

To view, for example, the log for July 1, 2020, enter:

atop -r /var/log/atop/atop_20200701

To change the log settings, open the atop utility configuration file. It is hosted in /etc/default/atop (in CentOS - etc/sysconfig/atop).


This parameter sets the interval for saving information about the load (in seconds). To set an interval of 20 minutes - enter the value INTERVAL = 1200


This parameter sets the path to the directory with logs.


This parameter sets the names of log files.

Restart atop for the changes to take effect:

systemctl restart atop.service

To speed up the site, we recommend moving the temporary MySQL files to tmpfs.

If you still have questions, please create a ticket to technical support.