Virtual combat: Two memory mechanisms for VM design

Source: Internet
Author: User

How much memory does a virtual machine need to be configured to fit? How can I best utilize the physical memory of the host? How to grasp the degree of over-commitment? This article from concept to actual combat to explain how to do a good job on the virtual machine memory resource planning.

How do I allocate memory?

First, we define some concepts.

The above figure is divided into three layers, they are app layer, OS layer and hypervisor layer respectively. For a physical server, all memory resources are allocated to separate operating systems and applications running above. The application sends the request first to the operating system, then the operating system schedules the physical memory resources.

Let's take the following scenario as an example to analyze how memory is allocated in each layer.

Let's say we start the ESXi host first, when the hypervisor loads the physical memory, which is the same principle that any other operating system loads physical memory. The memory loaded at this level is called the "Machine memory". \ hypervisor We then created the virtual machine on the ESXi host and set it to 4G memory (configured Memory Size), also known as "Guest physical Memory", because this is virtual hardware the memory allocated for the VM. For the operating system, this is no different from physical memory, and it is considered to have full control over the 4G memory. Then we start the VM, and the OS above starts running. It then runs an application that makes a request to the OS via system call (Syscall) and then gets the memory. This is called "Virtual Memory."

It says the memory allocation process, so how is memory released?

The app tells the OS through system calls to release unwanted memory. The OS believes that all of the memory set on the virtual machine is assigned to itself and does not release the guest physical Memory, but instead creates a free list to record that the memory can be reassigned. And hypervisor can't access this free list at all. So the physical memory cannot be freed at all.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/virtualization/

How does two hypervisor release physical memory?

The problem is that you don't expect to release the physical memory through the guest. So how does hypervisor release memory? There are several main technologies:

The TPS (transparent Page sharing) TPS defaults to run automatically. For example, a ESXi host running multiple virtual machines, their OS and app is very similar, the content of many memory pages must be the same, hypervisor will compare these pages, remove redundancy in physical memory, just keep the information of a single page. This reduces the consumption of physical memory.

Blooning

The Vmtools installed on the virtual machine includes the ballooningdriver. It tells hypervisor which inactive memory pages can be retracted. This has no effect on the performance that is applied on the virtual machine. On the principle of blooning technology, DELXU's blog illustrated the VMware Memory mechanism explained very clearly, praise one. I will not repeat them here.

Compression: The default is started. The system tries to compress the virtual memory page before starting swaping, and if it is less than 2KB, it can be saved in the Comression cache of the virtual machine.

Swapping:

If both tps,blooning and compression are in use, there is still insufficient physical memory. Then the last resort is swapping. This is likely to have a significant negative impact on application performance because of page swapping and disk. See Frank Denneman Bowen impactof host local VM swap on HA and DRS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.