[Notes about swap] 1. swap is generally referred to as a "swap space" and serves as a "virtual memory" on Windows ". 2. swap is actually a space on the hard disk. 3. the data stored in the swap cannot be directly used by the CPU. If the CPU wants to use swap data, it needs to first transfer the data from the hard disk to the memory, and then hand it to the CPU
Suggestions on swap 〗
1. swap is generally referred to as a "swap space" and serves as "virtual memory" on Windows ".
2. swap is actually a space on the hard disk.
3. the data stored in the swap cannot be directly used by the CPU. If the CPU wants to use swap data, it needs to first transfer the data from the hard disk to the memory, and then hand it over to the CPU.
4. swap stores data that is temporarily unavailable or frequently used.
5. The data speed from swap to memory is several hundred or even thousands of times slower than the speed from memory to cpu.
About insufficient memory 〗
1. the significance of swap is to store data that is not frequently used, rather than data that cannot be stored in the physical memory.
2. if the frequently used data cannot be stored in the physical memory, the kernel will be forced to allocate part of the data to swap.
3. if 2nd pieces of data are written, a large number of hard disk read/write IO will be generated next. for the reason, see section 2nd in the swap notes.
4. after the hard disk is connected, a large number of hard disk read/write IO will have the following consequences:
(1) the CPU will spend a lot of time waiting for hard disk I/O when processing computation, seriously affecting the server's response speed.
(2) other VPS on the same server will be affected (unless not the same hard disk is used ).
5. * Note the difference between "using swap" and "using swap ":
(1) When swap is used, the index data is stored in swap, which is fixed and does not occupy hard disk IO.
For example, although the system occupies 13 m of swap, it does not exchange swap.
(2) swap refers to the process of transferring data from swap to physical memory or from physical memory to swap.
For example, the system performs a large number of memory swap operations almost every second.
Suggestions for insufficient memory 〗
(1) if the memory is insufficient, upgrade the VPS memory in time. Otherwise, it will not only affect your own VPS system, but also affect other VPS.
(2) do not try to solve the problem of insufficient memory by adding swap. the root cause of the problem is that the physical memory is insufficient, and more swap is useless.