Virtualization & Containerization

Virtualization & Containerization

There are some cases when an application works on your system as you are the developer but your application fails to run on someone else’s system, it is due to missing packages, system configuration, hardware, OS or many other factors that are different in both the systems.

Also if we still want to run it on other’s systems we will have to make an environment similar to the development environment. Even if we can achieve this, What if we have to do this operation in hundreds of systems? There is a problem Right? Virtualization solved this problem.

Traditional servers were like normal computers only, there will be hardware and OS will be installed on top of it and then run or host application on it and these will be used for a specific purpose only but, there are many issues that came with this approach. Then came virtualization technology as a solution to it.

Virtualization:

It is the process of creating virtual instances of physical resources of a system. With this a virtualization layer was added between OS and Hardware, enabling users to run virtual servers/machines each with their own OS on one machine. This technology allowed businesses to run virtual machines and make the most out of systems and also opened doors for scalability and cost optimization.

How does it work?
Virtualization is possible due to a software layer called Hypervisor, it enables multiple operating systems to co-exist while sharing the same resources of a system. Virtual machines request when additional resources are needed from the physical hardware, and the hypervisor passes the request to the physical system and caches the changes.

There are 2 main types of hypervisor software:

  • Type 1 hypervisor directly runs on the hardware of the host machine and is responsible for managing resources and running VMs. Since it directly runs on top of hardware it is efficient.
    Examples: Microsoft Hyper-V, VMware ESXi and Citrix XenServer.

  • Type 2 hypervisor runs on top of the host operating system and depends on it to provide resources and support.
    Examples: VMware Workstation and Oracle VirtualBox.

Due to the presence of an additional layer (hypervisor), there is a noticeable decrease in performance unless more resources are allocated. This is solved by containerization.

Containerization:

Containerization is a lightweight alternative to virtualization. It is a process of packaging every component needed to run an application, including associated libraries This involves encapsulating an application with its dependencies and configurations as a single unit “image ” and run as a container with its own operating environment, and also allows to run multiple instances of single or multiple containers on a single host machine without needing any kind of intermediary software like hypervisor in virtualization, instead it uses host operating system’s feature to isolate containers and manage resource allocation., allowing them to be run consistently across different environments.

Popular container providers: Docker, Linux Containers(LXC), CRI-O

Virtualization and Containerization both are the same kind of technologies, differ in the way they operate, and both allow multiple applications to run on a single machine with isolated environments.

Which option to use?
If there is any specific hardware requirement for the application you are building and needs to target different OS then virtualization can be used.

Software-only requirements can be met by using containers.

Containerization and Virtualization can be used together as per business needs.