When your VPS or dedicated server has performance issues such as slow down's or application specific bottlenecks, you can usually find useful message is printed to the application’s error log or in the system-wide logs.
These logs can be found in /var/log/<application-name>
Keeping track of the approximate time the issue happened can be helpful when digging into logs to find clues as to what the issue may be and what has caused it.
The most common cause of server slow downs is one or more processes consuming a large amount of the system resources or in rare cases, unchecked zombie processes.
The easiest way to view the current usage of resources is to use the utility top
. top
allows you to view CPU utilisation, Memory usage, Disk activity, Tasks, Process Table and Load Average.As useful as top can be for checking resource usuage, depending on how intense the load or bottlenecks are, top may add to the issues rather than provide a solution in a quick manner because it provides output in real time and thus, needs a fair amount of resources itself to run.
In such situations, other system tools could provide the deep dive needed without being as resource intensive. Some tools that can be used are:
dmesg
dmesg (diagnostic messages) is a command on most Unix-like operating systems that prints the message buffer of the kernel. The output includes messages produced by the device drivers.
When initially booted, a computer system loads its kernel into memory. At this stage device drivers present in the kernel are set up to drive relevant hardware. Such drivers, as well as other elements within the kernel, may produce output ("messages") reporting both the presence of modules and the values of any parameters adopted. (It may be possible to specify boot parameters which control the level of detail in the messages.) The booting process typically happens at a speed where individual messages scroll off the top of the screen before an operator can read/digest them. The dmesg command allows the review of such messages in a controlled manner after the system has started.
vmstat
vmstat (virtual memory statistics) is a computer system monitoring tool that collects and displays summary information about operating system memory, processes, interrupts, paging and block I/O. Users of vmstat
can specify a sampling interval which permits observing system activity in near-real time.
The vmstat tool is available on most Unix and Unix-like operating systems, such as FreeBSD, Linux or Solaris.
mpstat
mpstat is a computer command-line software used in Unix-type operating systems to report (on the screen) processor-related statistics. It is used in computer monitoring in order to diagnose problems or to build statistics about a computer's CPU usage.
pidstat
pidstat is a command used for monitoring individual tasks currently being managed by the Linux kernel. It writes to standard output activities for every task selected or for every task managed by the Linux kernel.
iostat
iostat (input/output statistics) is a computer system monitor tool used to collect and show operating system storage input and output statistics. It is often used to identify performance issues with storage devices, including local disks, or remote disks accessed over network file systems such as NFS. It can also be used to provide information about terminal (TTY) input and output, and also includes some basic CPU information.
iotop
iotop is a Linux command. It is a top-like utility for disk input and output (I/O). Use this command to see I/O usage information output by the Linux kernel. It displays a table of current I/O usage by Linux processes or threads on the Linux system.
free
The Linux free command outputs a summary of RAM usage, including total, used, free, shared, and available memory and swap space. The command helps monitor resource usage and allows an admin to determine if there's enough room for running new programs. In this tutorial, you will learn to use the free command in Linux.
slabtop
slabtop displays detailed kernel slab cache information in real time. It displays a listing of the top caches sorted by one of the listed sort criteria. It also displays a statistics header filled with slab layer information.
sar
sar (System Activity Report) is a Unix System V-derived system monitor command used to report on various system loads, including CPU activity, memory/paging, interrupts, device load, network and swap space utilization. Sar uses /proc
filesystem for gathering information.
When an application has issues but the system is still operable, you can dig even further into the system calls to further isolate the root cause with a handy tool called strace.
strace
strace is a diagnostic, debugging and instructional userspace utility for Linux. It is used to monitor and tamper with interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.