Last update at :2024-04-24,Edit by888u
Someone asked me about swap. To be honest, I didn’t understand it. Then I checked it on Google and Baidu, and I got some general conclusions. If there are any mistakes, please leave a message and point them out! When we play VPS, we usually see several words related to swap: swap, burst, vswap. Here we talk about their relationship with memory and hard disk.
swap: (i.e., swap partition), similar to Windows virtual memory, means that when the memory is insufficient, a part of the hard disk space is virtualized into memory to solve the problem of insufficient memory capacity. This thing is a pure hard disk. When you start using swap, the I/O of the hard disk must have been affected! Swap is common in VPS based on XEN and KVM. You can manually change the size yourself. If it is an SSD hard drive, the effect will be much higher.
Burst: The full name is burst ram. This product is genuine memory. The operating efficiency is the performance of the memory. Under normal circumstances, it is the memory reserved by the hen, which can be used by you for a short period of time if the memory is insufficient. That is to say, you can only use it when the hen has enough memory.
vswap: OpenVZ can simulate a part of the memory as a swap area (swap) in the hard disk. This is vSWAP, a virtual memory swap area. In order to simulate the hard disk memory swap area, the read and write speed of this memory area will be slowed down to match the read and write speed of the hard disk. Although the reading and writing between the memory and the virtual memory swap area are not real hard disk I/O, programs that use this part of the memory will still be relatively slow. Once the server memory is insufficient, there is not enough memory to simulate swap. At this time, there will be no vswap but only hard disk swap.
To put it simply, if the merchant oversells and there is insufficient memory, then burst ram and vswap will not have much meaning. Without more memory, there will be no burst ram and vswap. At this time, it is not as good as swap, because swap can still hold on for a while. !
By the way, increase the swap size under XEN and KVM: Adding swap under openvz can be done numerically. There is no change in the effect. It is just self-deception. Under XEN and KVM, if the added swap space is an SSD, the effect will be even better!
1. Enter the directory
cd /var/
2. Obtain the SWAP file block to be added (here, 1GB is taken as an example)
dd if=/dev/zero of=swapfile bs=1024 count=1038336
3. Create SWAP file
/sbin/mkswap swapfile
4. Activate SWAP file
/sbin/swapon swapfile
5. Check whether the SWAP information is correct
/sbin/swapon –s
6. Add to the fstab file to start automatically when the system boots
echo “/var/swapfile swap swap defaults 0 0” >>/etc/fstab
Recommended site searches: server space, Hong Kong server recommendation, how to rent a server, Guangdong server rental, expired registered domain name, cloud server rental, US ASP space, PHP space rental, free foreign space, free foreign server,
发表评论