buffer 与cache 的理解

buffer 与cache :
A buffer is something that has yet to be "written" to disk.
A cache is something that has been "read" from the disk and stored for later use.

CPU(写) ------> buffer ------> disk(解决CPU与硬盘性能差异,待写数据放入buffer池)

CPU(读)------> cache <------ disk(命中缓存,不用每次去disk获取数据,命中率越高,IO读(bi)越小)

$ free -m
             total       used       free     shared    buffers     cached
Mem:          2006       1735        270          1         39        728
-/+ buffers/cache:        967       1038
Swap:            0          0          0 

# total = used + free + shared

'-buffers/cache used' = 第一行used - buffers - cached - shared;

'+buffers/cache free' = 第一行free + buffers + cached + shared;

#Swap 越高,说明内核置换cache越频繁,内存资源越紧张。

$  vmstat 1 3 #查看bi,bi:磁盘读,bo:磁盘写
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 277136  40616 745644    0    0    88   237 1188  526  7  2 91  0  0
 0  0      0 277136  40632 745636    0    0     0    64 1264  628  0  0 100  0  0
 0  0      0 277136  40632 745644    0    0     0     4 1258  607  0  0 100  0  0

#cache越大,bi越小


 

猜你喜欢

转载自blog.csdn.net/wangtingting_100/article/details/86093082