I’m not a server administrator, nor do I have sound knowledge with Linux but recently, I have been involved to setup a server on rackspace. Everything was going smooth, with 20 of my clients site being hosted on server until we got an email from Rackspace regarding over consumption of memory and complete use of swap needing to hard reboot the server. They asked us to oversee the issue and fix it. Now, I didn’t had any idea how to check memory and processes on server, I researched a bit and found this command name “free”. There were other commands which had helped me resolve the issue like top, htop, ps,etc.. which I will be explaining on my further posts. Let us go through this “free” command in Linux and how it works in more detail here.
Login to your server and give the ‘free’ command without quotes. Not sure, what client you use for ssh communication but I prefer SSH Secure Shell Client.
Below, is the output screenshot which consists of the four lines also, you will see the results are in Kb.
You might want to view the results in megabytes, so you can just add ‘-m’ option after free command to view results in megabytes(Mb) which is more readable.
Output screenshot as below:
First line consists of column headers, 2nd line provides you the memory usage including cached and buffered memory. You just need to concentrate on the third line, which tells you what memory is being used by the system and is not available for other process. In above screenshot you will see, 743 mb of 1998mb is used by different processes. I still have 1255mb of memory available which can be used by other tasks. That’s it.. If you are concerned with the 4th line mentioning swap, let me provide you brief info. on it. Swap is a disk-based memory space that can be configured on some servers and is used incase your application require so much memory that it had to resort to hard drive swapping to work. Consistent swapping or very high levels of swapping make you application run slow. You may need to upgrade to include more RAM, if it coninues to use swap memory even after optimization.
Regular monitoring of server memory utilization must be done on a regular basis. It helps you to have general idea of your server condition and alert you in advance for any possible problems. Like your server might be up and running but it may be struggling using higher level of swap becoming slower and slower. So. it’s better to know any issues beforehand than resulting into any downtime and non-operational site.