Containers vs VM

We have talked about how Virtual Machines or VMs have made life easier for development teams as one can just onboard a VM from a cloud service provider and deploy the application on it. One major challenge with Virtual machines is that they are heavyweight.

Let’s take a look at how virtual machines are designed to work

Image Source:

Rather than directly installing an operating system, there is a layer of hypervisor that abstracts underlying hardware. This allows separation of the OS layer, and one can independently install any OS without worrying about the infrastructure layer. As we can see each VM is a completely independent system in itself where an OS is managing hardware and software resources. Now the problem here is that OS itself is a heavy piece of Software and normally needs a good amount of processing capabilities in terms of CPU, RAM, and Storage.

To understand the scope of the problem, let us say we need to deploy three services for an application, a product detail service, a search service, and a shopping cart service. To keep them independently maintainable and scalable, it makes sense for us to deploy them separately. So we can take thee different set of VMs and deploy services. As we can see, that an additional burden we need to carry is each VM has its own OS that is eating up our compute resources.

The solution here provided by containers is to move abstraction one layer above the OS. That is, instead of directly installing our services or application servers on OS, we create containers above the OS layer, which gives us the flexibility to deploy multiple containers on a single OS.

The image below should clarify the though process.

Image Source:

The docker layer here represents the container engine. Docker is a technology, created by the namesake company which helps us implement the container-based deployments for our application. Rather than re-inventing the wheel, let’s take a look at definition provided by

Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in user space. Containers take up less space than VMs (container images are typically tens of MBs in size), can handle more applications and require fewer VMs and Operating systems.

Coming back to our example of three services, now instead of creating three machines we can generate three containers on single machine helping us use our resources in optimised manner.

Common Cloud Services

Cloud computing or Cloud has become a term that is used very loosely now in the software industry. It is important that we understand what the cloud is. If we think of the cloud objectively, it is nothing but a set of services clubbed together and being offered by various cloud services providers. These services can be as simple as getting a Virtual Machine off the shelf, or onboarding a sophisticated complex machine-learning algorithm to process our data.

Let’s think of a very simple application. What all you need to deploy a simple application and make it available to end-users?

Deployment for a simple web application

The bare minimum services that one needs for an application to be deployed are server, database, and storage. We are not talking about scalability, security, API gateway services for now to keep it simple. If we go to any cloud platform we do get all these services in common umbrella service types of Compute, Storage, and Database.

Amazon Web Services

Compute: Compute is the most basic set of services provided by a cloud service provider. In simple words, this is where you will deploy your code and execute it. The simplest form of the compute service is Virtual machines. You can provision VMs from the cloud and deploy tools and services needed for your application to work. You deploy your application and expose it to the outside world.

Storage: Second most important thing that an application will need is storage. You need to store images, files, logs, etc. for your application to work fine. All cloud services provide us with different storage options. Customized according to user needs with respect to performance, security, redundancy, etc.

Database: Another set of services that are core to any application is a database. The database itself has gone through many interesting transitions in the last few years. From just Relational databases, we have now a set of no-SQL databases, which includes a column-based database, document-based database, graph-based database, key-value database, and so on. All major cloud service providers have good support for all the common databases and provide additional features like encryption, redundancy, etc off the shelf.

Other important services: Though we have talked about only Compute, Storage, and Database so far, the cloud platform provides many more services. Services related to Networking, Security, Machine Learning, IoT, etc. are available off the shelf from cloud service providers.