Containers vs VMs
At first it seems like containers are the natural evolution of virtualization. VMs have been around much longer which makes them seem like old tech compared to containers. Containers and VMs also tend to be written about as if they compete for the future of cloud computing and it’s a battle to survive. The reality is that they aren’t exclusive from one another but are different technologies that have their own use depending on your needs.
What is a Virtual Machine?
Virtual Machines (VMs) are virtual computing environments that utilize provisioned hardware and their own isolated OS. They are themselves separate computing environments that can coexist when managed through a hypervisor.
Virtual Machines are basically computers themselves that sit either within a hypervisor or as a window on top of a host operating system. Each virtual machine is referred to as a guest while the hosting hardware or OS is considered ‘the host’. Because VMs are computers themselves, their performance is dictated by hardware specs.
Just like physical computers, VMs provision hardware to use and boot from. This means that just like a physical computer, boot times can depend on the hardware quality and specs. Fast hardware will generally boot a virtual machine faster. Also, because a VM has its own contained operating system it will have all the capabilities of a full operating system.
A big advantage of VMs is that operating systems can be installed separately. This means different OSs can run next to each other on the same hardware. Want to run a windows server next to a Linux server? No problem. Want to run a Linux server on top of windows? Again, you can do that.
The environment within a VM is totally separate so that multiple tenants can occupy the same hardware. VMs create separate environments for sensitive data and apps so they are secure even with multiple tenants using the hardware.
VMs are legacy, proven and trusted technology. They are relied upon by large organizations that require security and can be scaled for multiple functions.
But in the day of web apps, entire operating systems aren’t always needed which has given rise to a new technology called containers.
What is a Container?
Containers are often thought of as the next phase of the virtual machine because they are newer and create separate virtualized environments for applications making them sound like they serve the same purpose as virtual machines.
Containers are isolated environments to run single applications. They package app code and include all the necessary tools and packages needed to run and manage an app. They utilize a host operating system and share the same kernel between container environments. This means that containers only use what they need for the application itself while the host OS and libraries all function underneath.
Containers are useful when you only need an application hosted because the container packages and runs only what is needed for the app. Everything else is hosted by the main OS. When hosting multiple containers with apps this leads to resources being allocated more effectively, faster boot times and portability.
Keeping an environment light weight and decreasing boot times is important in the day of SaaS apps, but so is security. A strength of virtual machines is that if an OS becomes compromised in any way, it doesn’t affect other VMs because they are managed through a hypervisor not an operating system. There are exceptions like the hypervisor itself being compromised but this is exceptionally rare.
On the other hand, because containers don’t have their own isolated OS, the entire system could become compromised if its infected.
For this reason, even Google, one of the most significant contributors to the Kubernetes open sourced container project keeps its client’s containers within separate VMs to maintain extra separation. Google does however only use containers for its own Google search use.
The big appeal to containers other than fast boot speeds is their flexibility. Containers are lighter on processes. Without needing to manage entire operating systems to manage an app, it can make building, testing and managing the application within its own environment much slicker. Plus, container environments can be run almost anywhere making them easy to move between computers.
Should I use a Container or VM?
Though many consider VMs and containers to be competitors or an evolution in technology, that‘s not necessarily true. Both have use cases and will be prevalent in data server storage, application hosting and virtualization for the foreseeable future.
The use scenario for container technology is mainly in web applications, SaaS applications and web app programs. For these programs it is isn’t always necessary to have an entire virtual computing environment and isolating the application is generally enough. Using this approach can mean lighter workloads for your servers and faster boot times, which is critical for services.
Virtual Machines are going to find use mainly in their security, isolated OS environments, and flexibility of a full computer. Having your choice in a full operating system, and the ability to perform multiple functions within that VM will be useful for anyone that wants to go beyond running single applications. Examples include managing a website, having a database and perhaps a web application. A virtual machine will also allow you to store data for longer periods of time as opposed to containers which don’t store data once the container is deleted. You can also partition multiple VMs in separate environments to create another level of security.
But again, VMs and containers can work together and will likely be increasingly coupled in the future. Large IaaS providers who own the hardware will likely implement VMs to separate clients for additional security and streamlined management while using containers to run each customer’s services.
Both containers and VMs are critical components to the infrastructure of the modern web. New innovations are being pushed out every year bringing these technologies to the forefront of modern computing resulting in more efficient apps and services for end users.
Virtual Machine and containers both have their own advantages and disadvantages. Many developers are beginning to incorporate both extensively for added security, increased speed, increased scalability and the ability to isolate various computing functions.
Here’s a breakdown of both:
- Entire operating system functions
- Isolated OS
- OS choice
- Proven history
- Hardware dependent
- More computing load to process
- Support from the open-sourced community
- Streamlined for application testing
- Less computing load to process
- Easy scalability
- Newer technology that’s not as proven
- Potential to infect OS if compromised
- Designed to have more limited functionality than an OS