Introduction

Server load indicates how much work your system is handling. High load can slow down applications, websites, and services. Monitoring and optimising load is essential for maintaining server performance and stability.

Prerequisites

Before checking or reducing server load, ensure:

  • Root or sudo access to the server (via SSH)
  • Basic knowledge of the Linux command line
  • Backup of critical data before performing cleanup actions
  • Monitoring enabled

I. How to Check Server Load

1. Using w Command

w

Example output:

11:31:50 up 9:15, 8 users, load average: 0.81, 0.90, 0.91
  • Shows logged-in users and load averages (1, 5, 15 minutes)

2. Using top Command

top -c
  • Displays real-time CPU, memory usage, and running processes
  • Helps identify high resource-consuming processes

3. Check MySQL Connections

mysqladmin proc
  • Displays active MySQL processes
  • Look for:
    • Long-running queries
    • Too many sleeping connections

4. Check Apache (HTTP) Connections

pidof httpd
  • Shows active Apache process IDs

5. Using uptime

uptime

Example:

load average: 0.30, 0.44, 0.44
  • Quick overview of system load

II. Methods to Reduce Server Load

1. Identify High Traffic IPs

netstat -plan | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

For mail (SMTP):

netstat -plan | grep :25 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

2. Analyse Running Processes

pstree -paul

3. Clean Temporary Files

cd /tmprm -f dos-* sess_* .spamassassin*find . -user nobody -exec rm -f {} \;

4. Monitor Exim (Mail Queue)

ps -C exim -fH ewwwps -C exim -fH eww | grep home

5. Check Active Network Connections

netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

6. Handle MySQL Sleep Connections

mysqladmin proc | grep Sleep | awk '{print $2}' | xargs -n1 mysqladmin kill

7. Clear Shared Memory Segments

for i in `ipcs -s | awk '{print $2}'`; do ipcrm -s $i; done

8. Clean Exim Mail Queue

Remove frozen emails:

exim -bp | grep "*** frozen ***" | awk '{print $3}' | xargs exim -Mrm

Remove old mails:

exiqgrep -z -i | xargs exim -Mrmexiqgrep -o 432000 -i | xargs exim -Mrm

Conclusion

Monitoring server load using tools like top, uptime, and MySQL process lists helps identify performance bottlenecks. By cleaning unnecessary processes, managing connections, and optimizing services, you can effectively reduce server load and maintain system stability.

Leave a Reply