Performance – How to Reduce High Memory Usage on Linux Server

linuxmemory usageperformance

I have a LAMP server with following configuration.

CPU : Intel(R) Xeon(R) CPU

RAM : 32 GB

HDD : 80 GB

Running on virtual environment.

All the things in the server are running smoothly. But I have noticed that the RAM usage is the server is increasing each day without any reason.

This is the current memory usage on my server.

# free -g
             total       used       free     shared    buffers     cached
Mem:            31         13         17          0          0         10
-/+ buffers/cache:          1         29
Swap:            2          0          2

And you can see the last 8 weeks memory usage below.
http://i.stack.imgur.com/543jh.png

And i have executed the following command to find how much memory each process is consuming.

# ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'
         0.00 Mb COMMAND 
      2253.62 Mb /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock 
      1171.66 Mb java -jar /etc/vmagent/bin/VMAgent.jar 
       138.27 Mb /sbin/audispd 
       127.75 Mb /usr/sbin/named -u named -c /etc/named.conf -u named -t /var/named/run-root 
        74.29 Mb auditd 
        73.03 Mb automount 
        43.14 Mb /usr/bin/spamd --username=popuser --daemonize --nouser-config --helper-home-dir=/var/qmail --max-children 5 --create-prefs --virtual-config-dir=/var/qmail/mailnames/%d/%l/.spamassassin --pidfile=/var/run/spamd/spamd_full.pid --socketpath=/tmp/spamd_full.sock 
        43.14 Mb spamd child 
        43.14 Mb spamd child 
        37.13 Mb /usr/sbin/httpd 
        37.02 Mb /usr/sbin/httpd 
        36.52 Mb /usr/sbin/httpd 
        36.46 Mb /usr/sbin/httpd 
        36.23 Mb /usr/sbin/httpd ................

For troubleshooting , i have restarted the MySQL and APACHE servers. But the result was same. Restarting the entire server will fix the issue, but i want to know what is the real issue.

Let me know if you have any idea about this issue.

Thanks,

Arun S

Best Answer

-/+ buffers/cache: 1

You're using only 1 GB. The rest is system cache.