Importance Of Containers and Virtualization in Cloud Computing
By: Vishnu Aravindhan
Tags: Virtualization, Software Engineering, Storage, Containers, Cloud Computing

We will now talk about virtualization and containers, which have become a very important topic in the software engineering field, primarily because there’s a lot of focus on it when it comes to cloud computing.

But when these ideas came from?

Initially, what used to happen is when you used to write code, you would have a DevOps steam or finance steam, which would ask you which box do you want to buy for this code?

Capacity Planning

So you would do something called capacity planning, which is basically a bunch of guesses. So you make a bunch of guesses and you tell that this is the amount of computing I need, this is the kind of memory I’ll be required for this application. I’ll be needing this much storage. Finally, you go to the shop and you buy a computer.

Now, this is an investment, of course, you’re buying a computer. If you buy a small computer, the problem is what if your business scales up? So you went to the shop, you bought the computer, you made all that time and effort in investment and then what? Your business scaled up and you need to do this all over again. So what do you want to do is you don’t want to buy a small computer because that investment doesn’t make sense. You want to buy a large computer or a reasonably safe computer so that you don’t need to do this again and again. But the problem with this is that the initial hardware investment is very large. If you wanted a horizontal scale just on the basis of hardware, you would need to buy as many computers as possible.

Better Approach

So one of the approaches that organizations took was to let their employees use that single computer.

But if you have multiple people using the same resource then, there’s going to be some contention. So you want to isolate resource usage as much as possible.

The question was, can we do this for applications?

Working Module

Now, you have a program that requires a number of resources, which are usually memory, IO, processing, and disk. So that’s how you can think of your computer also. It’s a bunch of these four resources which can be used for running your program. Obviously, the more programs you have, the more resources you need, but you also want to do some sort of boundary management, which means that A does not interfere with B’s memory and C doesn’t interfere with A’s IO. And that responsibility is going to be taken up by the operating system. So now the operating system is the sole manager of these resources. When you write a program, you talk to the operating system saying that through your interface, I would like to book X amount of memory, Y amount of IO, and so on.

So you’ve seen the diagram, that this program over there with the interface, is picking up some of the space in terms of resources. Similarly, you can have multiple programs that are going to be taking up slices of the resources that the operating system can provide and the remaining is going to be unused.

The problem with this is that you can still have the same problems with shared compute, where, if the memory runs out because let’s say yellow takes up all the memory, then everyone else is upset.

Virtual Machines

What we would prefer to have is something like a very strong boundary, which is provided by something called virtual machines. And this concept is super interesting because the Virtual machine is like an operating system in itself. So it’s an operating system running on top of an operating system.

Technically, you can have the Blue box in the diagram as a hypervisor, but let’s assume that it’s an operating system and you’re running this on top of it. So it’s like the matrix effect. The real world is being hidden from you and you can interact with this fake world that you have without concerning yourself with what other programs are running on the same hardware. You’re now mainly concerned with the virtual machine that you have been assigned, which has been given a set of resources. This concept makes a new business model possible, which is called cloud computing.

Pros Of Virtual Machines

The basic idea is huge companies like Amazon and Google have a lot of hardware laying about what they can do is take all of the spare hardware and rent it out to small businesses. For example, InterviewReady. I can go to Google or Amazon and say that “Hey, please run my site.” I’m going to pay you some rent money, but I’m not going to be making that big investment of maintenance and upfront cost of buying a computer like where I am going to place it. So that is the rent cost of placing the computer, of maintaining that computer is taken care of.

I’m going to pay you some rent money, but I’m not going to be making that big investment of maintenance and upfront cost of buying a computer like where I am going to place it. So that is the rent cost of placing the computer, of maintaining that computer is taken care of. The other good thing is that my code doesn’t need to be platform dependent. I can think of a Windows computer and run Linux on top of it. So I have a 64 GB Windows computer, I can run let’s say, four or five Linux computers on top of it and my code doesn’t need to know that deep down there are windows running.

The third thing is that this is very flexible, the provisioning of these resources is quite dynamic. All I need to do is shut down my Virtual machine and restart a new machine. I don’t need to go to the shop and buy a different computer.

Amongst these three, I think platform independence is probably the game-changer here because if you remember Java when it came as a language so many people adopted because you no longer had to take OS considerations, you could push that onto the off steam. You just needed the .class file and you could run the program on any operating system.

Cons Of Virtual Machines

So this was a big deal because people could just go to these cloud providers and ask them for a virtual machine and they would get it very cheap. But one of the problems with the virtual machine is that when you’re running a program, you don’t want to start an entire virtual machine. It’s like booting up your computer. It takes some time. It takes a few seconds. And then the idea came up that, hey, you just need processing power, memory, disk, IO these four sources.

Containers

Taking all this into consideration, there came something like a lightweight Oses. They were a precursor for something called containers. Containers are effectively a form of virtualization. What they let you do is app isolation. You’re not going to be having all the features of OS isolation, you know virtual machines, but you don’t really need that. And the benefit is that you just need to tear down and build this lightweight container. So that’s faster when it comes to boom times. Interestingly, this process of building and tear down is called mounting and unmounting a desk.

Pros Of Container

In school, if you guys worked on CDs and stuff, we would mount and unmount disks that would be like a virtual machine, which would be allowing you to read the contents of the disk. Similarly, in a container, you actually specify the operating system and your disk requirements, and then the mounting process figures out the filesystem. Underlying file system, which you will be using through the interface of the container.

So technologies like Docker have done the same thing that Java did for programming languages. It’s a way for us to move all OS considerations back to the developer. The developer can actually specify that these are the resources they need. This is the operating system I’ll be running on. And you don’t need to worry about the hardware so much. Docker will handle that. It’ll create an interface that will be interacting with the hardware or the virtual machine, whatever be the case. It will create a container on top of it and let your programming interact with the interface. When it needs more memory, it just asks and gets it.

Cons Of Container

So the advantage of using containers is clear, but the major disadvantage that I can see is that containers also considered a little slow. There are also possible firewall issues that come up because you have containers, although it’s much lesser in containers than a virtual machine in my personal experience. Overhead of container management is also not worth it really for simple applications like places where you know that you don’t need containers as such.