Disclaimer

Wednesday, 20 November 2024

What is Load Average in the top Command in Linux?

 

What is Load Average in the top Command?

Load average is a measure of the amount of work the server is handling over time. It shows the average number of processes that are:

  1. Actively running on the CPU.
  2. Waiting to use the CPU.
  3. Waiting for I/O (like disk or network).

The load average is displayed as three numbers in the top command:


load average: 4.39, 2.90, 3.63

These numbers represent the system's average load over the past:

  • 1 minute (4.39 in this example).
  • 5 minutes (2.90).
  • 15 minutes (3.63).



How to Identify Too Much Load on the Server?

To know if your server is overloaded, compare the load average to the number of CPU cores (vCPUs) your system has.

  1. Load Average ≤ Number of CPU Cores:

    • The system is performing well; there's no overload.
    • For example, if you have 8 CPU cores and the load average is 4.39, the system is fine because the load is less than the CPU capacity.
  2. Load Average > Number of CPU Cores:

    • The system is overloaded because there are more processes waiting for CPU time than the CPUs can handle.
    • For example, if you have 4 CPU cores and the load average is 4.39, your server is at full capacity. If it climbs to 8 or higher, it means processes are queuing up.



Is There a Limit to Load Average?

There’s no fixed upper limit for load average, but practical thresholds depend on the number of CPU cores:

  • 1 core: Load average of 1.0 means full CPU utilization.
  • 4 cores: Load average of 4.0 means full CPU utilization.
  • 8 cores: Load average of 8.0 means full CPU utilization.

If the load average is consistently higher than the number of cores, the system is overburdened, and performance issues like slower response times or delays can occur.





How to Check for Too Much Load in Layman Terms

Imagine:

  • You have 4 counters at a bank (representing 4 CPU cores).
  • If 4 customers are at the counters being served, the load is 4. Everything is smooth.
  • If 8 customers are in the queue (4 being served and 4 waiting), the load average is 8, and the system is overloaded.

If the number of people (load) consistently exceeds the number of counters (CPU cores), the queue grows, and the wait time increases.





What Causes High Load Average?

  1. CPU-intensive Processes:

    • Long-running or inefficient processes consuming too much CPU.
    • Examples: complex SQL queries, large calculations, or badly tuned applications.
  2. I/O Bottlenecks:

    • Slow disks or high disk read/write activity causing processes to wait.
    • Example: database backups or logs filling up.
  3. Memory Pressure:

    • If RAM is exhausted, the system uses swap (disk), causing delays and higher load.
  4. Network Delays:

    • Processes waiting for data from external systems.



How to Identify and Reduce Load

  1. Use top or htop:

    • Look for processes with high %CPU or %MEM usage.
    • Example in top:

      PID USER %CPU COMMAND 2470184 mdatp 15.9 wdavdaemon
      • Here, the mdatp process is using 15.9% of the CPU.
  2. Check Disk I/O:

    • Use iostat or iotop to find processes causing disk bottlenecks.
    • Example:

      iostat -dx
  3. Reduce Load:

    • Terminate unnecessary processes: Kill or stop unimportant jobs.
    • Optimize applications: Tune Oracle SGA/PGA, queries, or indexes.
    • Upgrade resources: Add more CPU cores, RAM, or faster disks.


Key Points to Remember

  1. Load average represents the demand on system resources (CPU and I/O).
  2. Compare load average with the number of CPU cores:
    • Load ≤ CPU cores: System is healthy.
    • Load > CPU cores: System is overloaded.
  3. Use tools like top, htop, and iotop to identify high CPU, I/O, or memory consumers.
  4. Proactive tuning, upgrading hardware, or redistributing tasks can reduce load.



No comments:

Post a Comment

How to recovery PDB when PDB database is dropped in Oracle

  How to recovery PDB when PDB database is dropped :) [oracle@rac01 ~]$ sqlplus '/as sysdba' SQL*Plus: Release 21.0.0.0.0 - Product...