Article Title: Linux performance tuning-virtual memory. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Simply put, the virtual memory is a part of the hard disk, which is used to store page files that are frequently used in the memory. The advantage is to increase the memory utilization-to make pages with high usage frequency active in the memory area, and improve the CPU's data operation speed. In Linux, this region is called swap. Generally, the size should be set to twice the physical memory size.
Vm. swappiness is a Linux Kernel Parameter in the range of 0 ~ 100. It indicates the tendency of data exchange between the actual memory and the virtual memory area. A larger value indicates a larger tendency, that is, the more page files are exchanged, and vice versa. The default value is 60. You can view it in 'cat/proc/sys/vm/swappiness.
How much should this value be set to improve Linux performance? Of course, this is determined by the specific environment. On a CentOS machine, I set the values to 100 and respectively. below is the three data reports that run 'vmstat-S M 5. (The vmstat command is used to view the virtual memory status. The parameter-s m indicates that the Unit is M, and 5 indicates that a report is generated every five seconds .) Here we mainly focus on bi, bo, and wa values. bi indicates the number of data blocks read from the hard disk per second (because the hard disk is a block device ), bo indicates the number of data blocks written to the hard disk per second, and wa indicates the time when the CPU waits for the IO Device to be ready.
When the value is 0:
Procs ----------- memory ---------- --- swap -- ----- io ---- system -- ----- cpu ------
R B swpd free buff cache si so bi bo in cs us sy id wa st
0 2 0 1277 16 6340 0 0 7 3 1 1 0 2 91 6 0
2 0 0 1277 16 6340 0 9 778 1203 3901 0 5 78 17 0
0 1 0 1276 16 6340 0 0 4 510 1094 3855 0 1 96 2 0
0 0 0 1276 16 6340 0 13 294 1113 3896 0 3 89 7 0
2 0 0 1276 16 6340 0 12 462 1122 3954 0 2 96 2 0
0 0 0 1276 16 6340 0 8 6 1027 3915 0 1 98 0 0
0 2 0 1276 16 6340 0 19 982 1178 3894 0 2 79 19 0
0 0 0 1276 16 6340 0 0 10 666 1195 0 3 70 27 0
0 0 0 1276 16 6340 0 0 7 10 1031 0 2 98 0 0
0 0 0 1276 16 6340 0 15 9 1031 3902 0 5 95 0 0
2 2 0 1275 16 6341 0 0 7 1420 1275 0 2 67 32 0
0 0 0 1275 16 6341 0 6 290 1125 3939 0 1 89 10 0
0 0 0 1275 16 6341 0 0 11 18 1029 0 2 98 0 0
0 0 0 1275 16 6341 0 26 22 1037 3984 0 1 98 1 0
0 0 0 1275 16 6341 0 0 5 18 1027 0 2 97 0 0
0 0 0 1275 16 6341 0 0 6 10 1029 0 1 98 0 0
0 2 0 1275 16 6341 0 0 6 1106 1191 3935 0 1 81 18 0
1 2 0 1275 16 6341 0 0 18 1121 1245 3870 0 1 61 38 0
0 0 0 1275 16 6341 0 14 121 1086 3924 0 2 94 4 0
0 2 0 1274 16 6341 0 12 1264 1245 3925 0 1 73 25 0
1 0 0 1274 16 6342 0 8 777 1208 3897 0 4 74 22 0
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 1274 16 6342 0 8 267 1076 3870 0 5 95 0 0
0 0 0 1274 16 6342 0 6 391 1089 0 2 98 0 0
0 0 0 1274 16 6342 0 0 10 0 1033 0 1 98 0 0
2 0 0 1274 16 6342 0 0 5 0 1026 0 2 98 0 0
0 2 0 1274 16 6342 0 0 5 1016 1193 0 2 82 16 0
0 0 0 1274 16 6342 0 0 4 203 1092 0 3 90 7 0
1 3 0 1274 16 6342 0 6 1198 1243 3910 0 2 75 23 0
2 0 0 1274 16 6342 0 4 81 1062 3974 0 1 95 3 0
1 0 0 1274 16 6342 0 14 13 1029 3907 0 1 98 0 0
0 2 0 1274 16 6342 0 11 1231 1228 3960 0 4 71 24 0
0 0 0 1274 16 6342 0 0 10 222 1102 0 2 84 13 0
0 0 0 1273 16 6343 0 0 6 0 1032 0 2 98 0 0
0 3 0 1273 16 6343 0 6 1411 1314 4007 0 3 69 28 0
0 0 0 1272 16 6343 0 14 386 1157 4162 0 2 91 7 0
1 0 0 1272 16 6343 0 14 810 1170 3921 0 1 89 10 0
2 0 0 1272 16 6343 0 5 566 1137 3884 0 1 92 6 0
0 0 0 1272 16 6343 0 0 10 265 1073 0 2 98 0 0
0 0 0 1272 16 6343 0 54 802 1196 4131 0 7 83 9 0
0 0 0 1272 16 6344 0 7 7 1046 0 2 98 0 0
0 0 0 1272 16 6344 0 0 4 943 1206 3840 0 1 86 12 0
2 0 0 1272 16 6344 0 9 38 1033 3891 0 1 99 0 0
[1] [2] Next page