We’re living in the age of cloud-native everything, and any virtual machine advantages tend to get dismissed. VMs are increasingly seen as a legacy technology that lacks the versatility and performance benefits of newer solutions, like containers and serverless functions. If you’re deploying an application today, you are probably more inclined to do it on one of the latter types of “next-generation” platforms, rather than using boring old VMs.
To a degree, that trend is fair. Virtual machines are a less effective solution in many cases than alternative forms of technology.
Yet, this does not mean that virtual machines have totally outlived their usefuless. Just as the bare-metal environments (which virtual machines helped turn into a “legacy” technology two decades ago) still have their use cases today, there remain several good reasons to consider using a virtual machine instead of a container, a serverless function or some other new-fangled type of hosting solution.
The Case Against Virtual Machines
To explain why, let me first summarize the reasons why virtual machines may not be an ideal choice, as compared to alternative hosting technologies.
The most common reasons to avoid virtual machines, and instead choose something like containers to host your app, are the following:
- Overhead: Virtual machines consume more resources than a container.
- Speed: In some respects, virtual machines are slower. They take longer to start (possibly a minute or two, compared to seconds for a container). The apps they host may also not run as quickly due to the fact that some of the host system’s resources are tied up by the virtualization hypervisor, leaving fewer available for the app to use.
- Redundancy: Virtual machines were designed with the assumption that each machine would reside on a single server. While it’s possible to create redundancy for virtual machines by spreading them across a cluster of servers, doing so requires more effort--and is a more clunky process--than distributing an app across a cluster using containers.
- Bulky images: A virtual machine image that contains a host operating system (as most do) will typically consume at least several gigabytes of space, and possibly much more. In comparison, a container image could be just a few megabytes, since a container image doesn’t have to package a full operating system.
- Cloud-native: Virtual machines are a technology that became widespread decades ago, long before the cloud age. Because of that, there is something of a cultural bias against them, spurred by the notion that--unlike containers and serverless--virtual machines are simply not a cloud-native technology.
All of these points are true and valid. For many modern application deployments, virtual machines are not the best choice.
Reasons Why Virtual Machines Still Matter
Yet, there are still plenty of use cases where virtual machines stand out from the competition in a positive way. Consider the following reasons why you might want to keep your virtual machines, and avoid the temptation to jump on the containerized, cloud-native bandwagon.
Perhaps the biggest selling point for virtual machines is that, at the end of the day, they continue to offer the greatest amount of deployment flexibility. A virtual machine can be deployed almost anywhere, regardless of the operating system or configuration of its host. A Windows system can host a Linux-based virtual machine, and vice versa.
Containers offer some level of flexibility. A containerized Linux application doesn’t care which Linux distribution hosts it. But you still can’t run a Linux container or Windows, or a Windows container on Linux, unless you use a virtual machine to create the additional abstraction needed.
Security and Isolation
Container security has improved immensely since the debut of Docker in 2013. But it still leaves some cause for concern; indeed, security worries are a major reason why some teams opt not to use containers.
Some of those concerns may be assuaged as container platforms continue to mature and more security tools support them fully. However, it’s unlikely that containers will ever totally match virtual machines from a security perspective, due to the simple fact that containerized applications can never be isolated from each other to the same extent as virtual machines. Virtual machines don’t share each other’s kernel or other essential system resources in the way containers do.
While it’s true that containers are a more natural fit in many respects for distributed host environments, this feature can also make them harder to manage. When you have hundreds of containers spread across dozens of servers, things quickly become difficult to control. That’s why you use an orchestrator like Kubernetes, of course, which automates much of the management. However, the orchestrator itself adds another layer of complexity that you have to set up, manage and secure.
Large-scale virtual machine deployments require orchestration solutions, too. But they are rarely as complex to manage as a container deployment. With virtual machines, there are simply fewer moving parts, and fewer overlapping layers of infrastructure.
Virtual Machines Are the Original Cloud
Finally, let’s address the cultural bias against virtual machines. Virtual machines may predate the cloud, but that doesn’t mean they’re foreign to it. IaaS services based on virtual machines were the first major cloud-computing service rolled out by public cloud providers like AWS in the mid-2000s. And they remain a key part of the offerings of those providers.
Containers and other so-called cloud-native solutions may be hotter these days. But don’t make the mistake of assuming that virtual machines are somehow not also a cloud-native technology. Without virtual machines, the cloud would never have become a thing in the first place.
For many IT teams, it’s high time to stop worrying and learn to love Docker (and whichever other modern, cloud-native application hosting technologies suit your liking). But that doesn’t mean abandoning virtual machines entirely. Virtual machines still have an important role to play in many clouds, and it would be a mistake to write them off based on the simple assumption that they are an “old” technology.