Does our server need more RAM?

Hi Guys,

Can anyone let me know if there is a good way to determine if our server needs more ram?

top - 10:51:40 up 173 days,  5:28,  3 users,  load average: 0.67, 0.55, 0.52
Tasks: 149 total,   1 running, 147 sleeping,   0 stopped,   1 zombie
Cpu(s): 19.1% us,  2.5% sy,  0.0% ni, 77.7% id,  0.5% wa,  0.0% hi,  0.2% si
Mem:   1034572k total,   941848k used,    92724k free,    15992k buffers
Swap:  2096472k total,   280836k used,  1815636k free,   384832k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
11417 apache    15   0 41356  14m 3744 S  8.3  1.4   0:00.86 httpd              
11416 apache    16   0 44612  17m 3740 S  6.6  1.8   0:01.20 httpd              
18984 mysql     15   0  176m  26m 3944 S  4.6  2.7   3598:55 mysqld             
 9891 apache    15   0 41884  17m 5864 S  4.6  1.7   0:04.95 httpd              
 5511 apache    15   0 53768  29m 6020 S  4.0  2.9   0:21.05 httpd              
 9549 apache    15   0 44352  19m 5840 S  4.0  1.9   0:06.07 httpd              
 6152 apache    15   0 45572  20m 5932 S  3.7  2.1   0:13.74 httpd              
11419 apache    15   0 42888  15m 3256 S  3.7  1.6   0:00.86 httpd              
11407 apache    15   0 42004  14m 3252 S  2.7  1.5   0:01.17 httpd              
 4462 apache    15   0 45852  21m 6092 S  0.3  2.1   0:23.25 httpd              
 8977 root      15   0  4516 1504 1212 S  0.3  0.1   0:00.06 bash               
 9547 apache    15   0 45400  20m 5864 S  0.3  2.0   0:06.71 httpd              
11442 root      16   0  2020 1052  804 R  0.3  0.1   0:00.09 top                
    1 root      16   0  1744  492  460 S  0.0  0.0   0:15.05 init               
    2 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0        
    3 root      34  19     0    0    0 S  0.0  0.0   0:09.01 ksoftirqd/0        
    4 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0 

cpu.png

mySQL.png

memory.png

load.png

Subtract your cached RAM and your buffered RAM from your used RAM and that is the actual amount of memory consumption by your server’s processes. According to your graph your average memory consumption is 595.38MB. You can also use the command “free -m”. There is a line starting with “-/+ buffers/cache” that will calculate this for you. Until you see your actual used memory minus the cached and buffered RAM at around 90-95% I wouldn’t worry. Have you been noticing performance issues?

No, performance has been spot on. We just had plans to host another heavy traffic site. I guess we should do that and then see how it behaves.

             total       used       free     shared    buffers     cached
Mem:          1010        849        161          0         71        334
-/+ buffers/cache:        443        566
Swap:         2047        350       1696

All looks good. :slight_smile:

Thanks for getting back to me. :slight_smile:

From what I see, you have used your swap memory, and from what I understand, when this happens is because you don’t have enough RAM. I would suggest upgrading memory, as they aren’t that expensive anyway :slight_smile:

Please feel free to correct me if any of my opinions/statements are wrong.

I think swap is like the pagefile in a windows system and its normal for it to be used

Swap is not always a bad thing. Linux will swap instead of shrinking the cache in some cases, whatever it decides is most effective at the time based on recent activity. There is a “swappiness” value in Linux that determines whether it will utilize swap or trash some cache for the process in need. The default value in most cases is fine, although decreasing this value will of course make swapping less common, it doesn’t eliminate swap.

Databases will also utilize swap space if the key buffer size is too large. Some mysql optimization may reduce the amount of swap being used. Mysql performance may take a hit if it is swapping often.

If there is a performance issue and you’ve done what you can as far as optimization, it may be time to look at upgrading hardware or just adding RAM.

I like to keep as much in memory as I can and tend to keep more RAM in the system than I apparently need.