Virtual machines (VMs) and containers are both virtual environments that use software instead of a physical machine to isolate applications into a self-contained unit. But VMs and containers are built and run differently, which affects their capabilities and the costs of using them.
Servers
To understand VMs, let’s start with a basic understanding of servers. They’re called servers because they serve up applications, information, or other services to other computers. VMs are actually virtual servers in that they serve up an application to other computers. VMs are deployed on a physical computer or server, called the host. You could run a VM on your personal computer, but companies, which run dozens or hundreds of VMs, typically house their VMs on a physical server.
Before hosting company applications in the cloud, companies housed them on physical servers, which were stored in racks in a company’s data center. In contrast to commercial applications like Word and Excel, company applications are created by companies to allow employees and customers to do things like download documents or order items or services. Each individual company application would sit on an individual physical server. Each time IT planned to create a new application, the team would have to decide how big of a server to buy to host the application. Deciding on the size of the server to purchase was always a conundrum as IT could never be sure how much computer resources—computation (CPU), memory, and storage—would be needed to host a new application. If IT ordered a server that had far more resources than was needed to host a particular application, IT could get scolded for spending too much money without cause. IT could almost always buy a server that fit the application’s needs for the first few months. But if the application turned out to be more popular than expected, in time the server’s resources would not be enough to handle the traffic, which would hinder the application’s performance. Hence, IT could get scolded for not thinking ahead and planning for growth in traffic.
When an application on a physical server lacks needed resources to handle increased traffic, the application slows down or, worse, crashes. If you’ve ever tried to complete a form on a website and sat there waiting for the app to let you proceed from one question to the next, you know how frustrating it is to interact with an app that lacks resources to work well. But those problems became rare when companies began using VMs because more resources could easily be allocated to handle nearly any amount of traffic.
Virtual Machines
As stated above, a virtual machine is a virtual computer that serves information to a user. To better understand what a VM is, let’s start with something we know: a Word document. Although a VM is more complex than Word document, a VM is kind of like a Word document in that they are both virtual—meaning you can’t touch them—and they both contain information. The VM contains images and code just as a Word document may contain images and text, which is a type of code, or language. The text in a Word document could be in English, Spanish or some other language, and the code in the VM could be in Java, C#, or another language.
To create a Word document, you need special software like Microsoft Word, Word Perfect, or Google Docs. So, too, to create a VM you need software like VMware, VirtualBox, or QEMU.
Creating a VM
Using a physical computer and software, a user can create a VM. The VM can reside on a physical computer, but VMs take up a lot of resources, so users at organizations typically use their computer to create a VM but save it on a VM server, which is a physical server. These days, VM servers are just referred to as servers, but they’re called VM servers because they were purpose-built to house virtual machines. VM servers can host dozens of VMs and can be located in a company’s data center, in a data center the company rents, or in a data center belonging to a cloud service provider like Amazon Web Services (AWS) or Microsoft Azure.
Just as you can create many instances of the exact same Word document and can save them in different folders on your computer, on other computers, on storage devices, or in the cloud like in Dropbox, you can also create different instances of a VM containing an application that can be stored on various computers, servers, storage devices, and in the cloud. The benefit of having different instances of a VM is that if one gets too much traffic at any point, you can spin up another instance of the VM quickly to handle the extra traffic. And if one VM breaks, another VM can come on line automatically and take over seamlessly, so users are totally unaware of the troubles behind the scenes.
Resources
A computer or server that hosts a VM is known as the host, while the VMs that reside on it are known as guests. There is a layer of software in between the host OS and the VM called the hypervisor, which creates and runs VMs on a server (See fig. 1). The hypervisor allows one host to support multiple guest VMs by sharing the server’s resources—memory, processing and storage.