containers vs virtual machine — What is the Battle All About?

Shivam Agrawal
techburst
Published in
4 min readJan 30, 2018

There is always a debate between containers and VMs as both have strong features, each of which have their own advantages and limitations. However in recent years the containers vs virtual machine discussion has become the talking point in the IT world. Due to the invention of modern technologies like cloud, and words like resource utilization, Zero downtimes, Scalability, portability, Easy accessibility, containers and vms become the topic of debate. Let’s explore some of these points:

1.Increase use of Cloud: With the increase use of cloud (like AWS, Azure, Google, IBM Cloud), provisioning of the virtual machines become the matter of minutes. With the help of Cloud, we can provision a VM in seconds and make it ready to use very speedily and we pay only what we use. Various Cloud providers also supports the containers like AWS. But the use of both depends on use case to use case.

2.Scalability: Scalability also becomes the major discussion point in designing the infrastructure. Since today’s application needs to scale based on the demand. Containers and VMs are both scalable in nature. We have to choose between these two on the basis of the requirement.

3.Portability: Containers provide the portability feature, means we can migrate the applications running on containers very easily. However this feature is not in VMs. For example if we have an applications running in AWS VMs, it is very difficult to migrate on Azure or on any other cloud. However containers are very lightweight in nature and are easily shipped or migrate from one cloud to another.

4.Resource Utilization: In past years we use data centres in which we have large servers which often use large spaces and always underutilized. The use of VMs make deploy of all these systems on a single large machine and make fully utilized. Then containers come into picture which are very cost effective and easy to use.

Use cases of containers and vms:

The use of containers moves the architecture making as microservice architecture i.e if you have an microservice architecture then containers have no barrier. Microservice makes the application loosely coupled as one component is not depend on the other component. So if your application code is written this way, you can simply use containers. Microservice architecture breaks an application into small components so that one component is run on one container.

Also by leveraging the containers in our infrastructure, we can scale each component on demand. We not need to scale the whole application therefore saves a lot of resources.

The legacy applications which are highly coupled in nature means each component are dependent on each other and applications are dependent on the underlying hardware are generally prefers to run on the Virtual machines rather than in containerized environment. Applications running on Virtual machines have better performance. For example suppose application running on VMs and one server have high CPU or memory utilization while another one have less CPU or memory utilization. Then you can move VMs to that server which have less CPU and memory Utilization. VMs also give advantages in case of maintenance, High availability when compared to physical servers.

Comparison Between Containers and VMs:

  1. Architecture → In Virtual Machines there is a layer of the hypervisor between the hostOS and GuestOS. Therefore each Guest OS has its own kernel means Virtual Machines with the different operating system runs on the same physical hardware.Each VM has its own binaries, applications running.Since each VMs has its own binaries, the size of each vms is about 1GB, therefore VMs are heavyweight in nature. Also for processing any command, execution takes more time due to additional layer of hypervisor. While in case of containers, the kernel is shared between the hostOS and containers. It means we can only launch same kernel containers as host kernel. Since the containers don’t have their own kernel, containers are very much lightweight in nature and size is about 100MBs. Also execution of commands are very fast.
Architecture

2.Building and shipping ( Portability ) → Due to lightweight nature of the containers, containers are shareable in nature and building and shipping the images consisting of applications along with their dependencies. Also containers are used in a variety of public and private clouds deployments for accelerating the dev and test environments with the help of shipped images. However since the VMs are heavyweight in nature and have own kernel they are not able to easily shipped from one machine to another.

3. Security→ Since the containers shared the same kernel space as the host machine, if any user have the admin permissions of the container, the host machines can be cracked. However in case of Virtual machines, host and guest machines have the different kernels and are segregated from each other, security is more prominent in case of virtual machines than containers.

4. Use-cases → Containers are generally useful if you have microservice architecture, as it allows to use containers functions properly. If you need a full platform running on a single system, you can go with the Virtual machines.

As both the containers and the virtual machines have their own advantages and limitations, there is a always a difficult decision to choose one of them since the decision is based on the features, requirements and type of architecture required. Generally as most of the applications are cloud based and leverage private and public cloud for the infrastructure, containers becomes the prominent choice as the deployment platforms. Containers provides easy, fast, scalable deployments for the applications. However virtual machines are still in action if the application is tightly coupled in nature.

--

--