VM is a piece of software that allows you to install other software inside of it so you control it virtually as opposed to installing the software directly on the computer.
While a container is software that allows different functionalities of an application independently.
2.
Applications running on a VM system, or hypervisor, can run different OS.
While applications running in a container environment share a single OS.
3.
VM virtualizes the computer system, meaning its hardware.
While containers virtualize the operating system, or the software only.
4.
VM size is very large, generally in gigabytes.
While the size of the container is very light, generally a few hundred megabytes, though it may vary as per use.
5.
VM takes longer to run than containers, the exact time depending on the underlying hardware.
While containers take far less time to run.
6.
VM uses a lot of system memory.
While containers require very less memory.
7.
VM is more secure, as the underlying hardware isnβt shared between processes.
While containers are less secure, as the virtualization is software-based, and memory is shared.
8.
VMs are useful when we require all of the OS resources to run various applications.
While containers are useful when we are required to maximize the running applications using minimal servers.
9.
Examples of Type 1 hypervisors are KVM, Xen, and VMware. Virtualbox is a Type 2 hypervisor
Examples of containers are RancherOS, PhotonOS, and Containers by Docker.
Once upon a time, in an old town, there was a grand house that many families shared. This large house came with shared kitchens, bathrooms, utilities, and backyards.
While this communal living saved money, it also led to clashes and conflicts. Each family had different needs, and the shared space couldnβt always accommodate them all. Eventually, these families found themselves unhappy with the constant disagreements and lack of privacy.
In the digital world, this grand house scenario is akin to hosting multiple pieces of software on a single physical server. Just like the families had varied needs, different software applications often require different runtime environments. This shared environment led to conflicts and inefficiencies, causing frequent failures.
The Move to Single-Family Houses
Displeased with the conflicts, the families decided to move into their own single-family houses. Each house was self-contained, and the families enjoyed privacy and control over their living conditions.
In isolation, each software application runs in its own machine, complete with its own operating system. This separation reduces conflicts and ensures that each application has the resources it needs.
However, just as maintaining separate houses can be costly and labor-intensive, managing multiple machines also comes with its own set of challenges.
So they all moved to an apartment,
1. Independence and Privacy
Apartment Analogy: In an apartment, you have your own private space with your own front door, allowing you to live independently from your neighbors. You control your own environment, including how you decorate and maintain it.
VM Justification: Similarly, a virtual machine provides an isolated environment where your software runs independently of others. Each VM has its own operating system, ensuring that different applications or services do not interfere with each other. This setup offers a high level of privacy and control over the software environment.
2. Resource Allocation
Apartment Analogy: Just like an apartment building has multiple units, each with its own utilities and space, you get a designated portion of resources such as electricity and water. This separation means youβre not competing for resources with other tenants.
VM Justification: With VMs, each instance is allocated a specific share of the host serverβs resources (CPU, memory, disk space). This means that your application operates with a guaranteed set of resources, reducing the risk of performance issues caused by other applications running on the same physical server.
3. Customization
Apartment Analogy: In an apartment, you have the ability to make certain customizations to your living space. You can adjust the thermostat, choose your own paint colors, and arrange furniture as you please.
VM Justification: Virtual machines offer similar flexibility. You can customize each VMβs operating system and environment according to the specific needs of your application. This customization helps in optimizing performance and configuring the system to handle specific tasks or software dependencies effectively.
4. Cost Management
Apartment Analogy: Renting an apartment often involves paying a monthly rent that covers utilities and maintenance. You have a fixed cost structure, and you can budget accordingly.
VM Justification: Using VMs can also offer predictable cost management. You pay for the resources you allocate to each VM, often with the flexibility to scale up or down based on demand. This allows you to manage expenses more effectively compared to maintaining a large physical server.
5. Shared Infrastructure
Apartment Analogy: While each apartment is independent, they share the buildingβs infrastructure, such as the roof, walls, and common areas. This shared infrastructure helps keep costs down for everyone.
VM Justification: Virtual machines share the same physical hardware but provide separate, isolated environments. This shared infrastructure helps reduce costs compared to having dedicated physical servers for each application or service.
6. Scalability
Apartment Analogy: If your needs change, you can move to a different apartment with more space or different amenities. The apartment complex can accommodate your changing requirements without requiring a complete overhaul.
VM Justification: Virtual machines are highly scalable. If you need more resources or additional instances, you can easily create new VMs or adjust the resources of existing ones. This flexibility allows you to adapt quickly to changing demands or workloads.