Memory ballooning in OS
Memory Ballooning :
Memory ballooning is a feature of most virtualization platforms to make more efficient use of physical memory for virtual servers. Memory ballooning is a critical component of modern virtualized data storage architectures. With both physical and virtual assets requiring memory resources, a variety of methods for claiming, releasing, and reclaiming memory are required.
Memory ballooning is a common virtualization technology technique that makes use of virtual machine memory. Memory ballooning is a memory management feature found in most virtualization platforms that allows a host system to artificially expand its memory pool by utilizing or reclaiming unused memory previously allocated to various virtual machines.
This is accomplished by installing a balloon driver on the guest operating system, with which the hypervisor communicates when it needs to reclaim memory via ballooning.
You can think of it as “stretching” regular physical memory to a greater extent. This enables a server with 32 GB of memory to host up to 64 GB of virtual machines (actual mileage will vary based on the workloads).
What is a Hypervisor?
Memory ballooning occurs within the context of a virtualization hypervisor. A hypervisor is the technology that allows virtual machines to run by providing a virtual abstraction layer for software.
Today, several hypervisor technologies are widely used, including VMware ESXi, Microsoft Hyper-V, and the open source Xen and KVM technologies. Each hypervisor can be used to enable guest virtual machines, which run operating systems and applications in a virtualized fashion.
Drivers are used by the hypervisor across running guest virtual machines to handle various requirements, such as resource constraints such as virtual CPUs, disc space, and memory. The balloon drivers operate across virtual machines, allowing a hypervisor to reallocate memory from one virtual machine to another.
Process of Memory Ballooning :
Understanding how a hypervisor works is inextricably linked to understanding the memory ballooning process. A hypervisor abstracts finite system resources and then allocates them to virtual machine processes that are running.
- Host Physical Memory –
The underling server or cloud platform has a set amount of installed system memory, which represents the absolute total amount of available memory.
- Guest Physical Memory –
In order to provide resources to running virtual machines, the hypervisor is given a portion of the host’s physical memory. The maximum amount of memory available to the hypervisor is referred to as the guest physical memory.
- Guest Virtual Memory –
The hypervisor allocates a portion of its total memory resources to the running guest virtual machines as virtual memory.
In the memory ballooning model, one virtual machine that, for example, had 8 GB of guest virtual memory allocated to it but was not using it could have some of that RAM reallocated to another running virtual machine that needed the extra memory.
The balloon driver keeps track of memory allocations as they move from one virtual machine to the next. The primary goal of memory ballooning is to provide a virtual machine with the memory it requires to meet a spike in process or application demand. This occurs even if it does not normally have sufficient memory allocated to it.
Issues with Memory Ballooning :
- High Balloon Memory Utilization –
High utilization is one of the potential problems that can arise. It is possible that the balloon driver will consume so much memory that the hypervisor will not have enough resources to operate at peak performance.
- Performance –
If multiple virtual machines request balloon memory at the same time, there may be a spike in CPU and physical disc usage as the hypervisor pulls resources via memory swapping techniques, degrading overall system performance even further.
Memory Ballooning importance :
- Resource optimization –
Memory ballooning takes memory from virtual machines that aren’t currently using all available memory, and then reallocates the unused memory to a virtual machine that needs the extra resources.
- Memory availability –
Memory ballooning, as opposed to simply not providing a virtual machine with the resources it requires due to a spike in demand or process, provides more memory when needed.
- Lower cost –
Memory efficiency reduces the need to deploy more physical servers or allocate more physical memory, which incurs additional operational and energy costs.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.