Memory ballooning in the OS
You might have studied many memory management systems OS uses to utilize the memory, but a special type of memory management is used nowadays to manage memory, and this is system is known as Memory ballooning. Its frequent use is observed in virtual memory dealing platforms, like VMWare, open-source KVM, etc. The most basic image of this system can be done by imagining that there is a balloon, filled with air, kept in a cuboidal box like the same shape your OS looks. Now, imagine there is a pump attached to the mouth of the balloon, and it can be made large, but up to some extent only. This extent can be the unclaimed memory previously used by the previous virtual machines.
The communication between these virtual machines is done by the hypervisor.
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.
- For the management of memory in Memory ballooning, the host server is kept responsible. The host server will reclaim memory that is currently not used by less busy processes going in VM, and it will direct that memory to a process that needs it more urgently.
- So, for theoretical understanding, we can imagine that the system with 32 gigs can expand its memory up to 64 gigs. Again, these numbers are theoretical in nature. The memory allocation by the host machine can be less or more than the given value.
Balloon drivers :
Now, we will see how balloon drivers in each connected guest machine are responding in the Memory ballooning.
- Whenever a machine needs some memory for reclamation, the hypervisor registers a request for reclamation of a specific memory, and that no other system should acquire it.
- In case, the memory falls short according to the balloon requirement, then a rearrangement between the VM can be done, and the balloon memory requirement can be fulfilled by sharing or swapping the memories. Good architecture should not have this occurring too much, as it can exhaust the resources too much.
Ballooning software in the VM :
Softwares like VMWare require that you should first install the ballooning software in the VM to start using your VM in VMWare.
- The size of the balloon depends on how much memory is required by the VM. According to the requirement, the size of the balloon can be increased, or decreased, thus making Memory ballooning more dynamic in nature.
- To ensure that the performance is kept at top-notch, you should have a good amount of size in all the host machines, as the balloon drivers will remember the active memory usage of all the other host machines.
- One thing that this system ensures is that, although the memory expansion is done, the memory in current usage, that is the active memory should not exceed the host memory.
(active memory)<(host memory)
- In case of many virtual machines are activated at the same time, then a common understanding would be that this will increase the workload suddenly on the hypervisor, and the whole ecosystem, but the advantage of using Memory ballooning is that it will not degrade the performance.
- The same goes when many virtual machines join, and it creates a spike in the connections, so this problem also will not create degradation in the connection.
Now, let’s take a look at its advantages are as follows.
- Even if the workload increases in the connection, the ballooning will not allow the system to degrade.
- The biggest advantage of implementing this system is that it will utilize the most memory available in the connection.
- It is dynamic in nature, so this technique can be modified according to the industry or the company’s requirements.
As the Memory, ballooning seems to be a very good option for implementation, but it holds some disadvantages are as follows.
- Overutilization of resources is When a balloon takes a lot of memory, and the hypervisor becomes scarce of giving memory to the incoming needy balloons.
- As the hypervisor uses the memory swapping and sharing principle, if more than one virtual machine, inactive state, requests for memory, then it can hamper the system performance. So, we should use the mutual exclusion principle.