epcim
10/20/2015 - 3:59 PM

linux RAM memory.howto.md

linux RAM memory.howto.md

linux performance, memory tunning / tools

  • lsof
  • vmstat
  • iostat
  • free -o

Find the process that eats the most

ps -aux | sort +5n

vmstat

Example1:

19:48> vmstat -d                                                        <epcim@dontpanic:~
disk- ------------reads------------ ------------writes----------- -----IO------
       total merged sectors      ms  total merged sectors      ms    cur    sec
ram0       0      0       0       0      0      0       0       0      0      0
ram1       0      0       0       0      0      0       0       0      0      0
ram2       0      0       0       0      0      0       0       0      0      0
ram3       0      0       0       0      0      0       0       0      0      0
ram4       0      0       0       0      0      0       0       0      0      0
ram5       0      0       0       0      0      0       0       0      0      0
ram6       0      0       0       0      0      0       0       0      0      0
ram7       0      0       0       0      0      0       0       0      0      0
ram8       0      0       0       0      0      0       0       0      0      0
ram9       0      0       0       0      0      0       0       0      0      0
ram10      0      0       0       0      0      0       0       0      0      0
ram11      0      0       0       0      0      0       0       0      0      0
ram12      0      0       0       0      0      0       0       0      0      0
ram13      0      0       0       0      0      0       0       0      0      0
ram14      0      0       0       0      0      0       0       0      0      0
ram15      0      0       0       0      0      0       0       0      0      0
hda   1747423 1722507 34275438 33491725 398011 2035996 18926226 72280827      0   9887
hdc       10      0      40      12      0      0       0       0      0      0
md0        0      0       0       0      0      0       0       0      0      0
sda   134911 298261 3396924 2170705  77326 4327021 6808781 478157869      0   1694

Example2:

19:48> vmstat -D                                                        <epcim@dontpanic:~
           20 disks 
            6 partitions 
      1882345 total reads
      2020768 merged reads
     37672410 read sectors
     35662455 milli reading
       475337 writes
      6363017 merged writes
     25735007 written sectors
    550438696 milli writing
            0 inprogress IO
        11581 milli spent IO
19:49> vmstat -s                                                        <epcim@dontpanic:~
      1035228  total memory
       588612  used memory
       518728  active memory
        19612  inactive memory
       446616  free memory
         2180  buffer memory
       124376  swap cache
      1028112  total swap
       508080  used swap
       520032  free swap
       651151 non-nice user cpu ticks
         1947 nice user cpu ticks
       350782 system cpu ticks
      2739314 idle cpu ticks
       978660 IO-wait cpu ticks
         9528 IRQ cpu ticks
            0 softirq cpu ticks
     18836245 pages paged in
     12867683 pages paged out
       905866 pages swapped in
       657287 pages swapped out
     57858211 interrupts
    172058571 CPU context switches
   1144039230 boot time
      1497416 forks

Example3:

19:49> vmstat -a                                                        <epcim@dontpanic:~
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free  inact active   si   so    bi    bo   in    cs us sy id wa
 0  0 508080 449408  17196 518396   77   56   398   272  315     6 14  8 58 21

iostat

19:51> /usr/bin/iostat -k -t -x                                                                                             <epcim@dontpanic:~
Linux 2.6.9-22.0.2.EL (dontpanic.cz.ibm.com)    04/03/2006

Time: 07:55:29 PM
avg-cpu:  %user   %nice    %sys %iowait   %idle
          13.74    0.04    7.60   20.69   57.92

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await  svctm  %util
hda         36.15  42.79 36.96  8.38  724.06  397.98   362.03   198.99    24.75     2.23   49.04   4.60  20.86
hdc          0.00   0.00  0.00  0.00    0.00    0.00     0.00     0.00     4.00     0.00    1.20   1.20   0.00
sda          6.34  90.74  2.86  1.63   72.21  143.03    36.11    71.51    47.86    10.07 2239.82   7.99   3.60