From the beginning of the time of people of software industry have used different ways to host their software / systems / applications. Imagine back in that day you had an application build by yourselves and you may have set up a single physical server and host your application through that.
At first you may think that way is “okay” for you. But when you start to implement and cater the needs of users problems arise.
Imagine you are going to develop a mobile app which you have to host so the users can use it. And the system you are going to implement may have several components , such as an application server (ex :- tomcat server), Identity management server, API manager, load balancer (ex :- nginx) etc. For the sake of simplicity let’s assume you have only below components in your system.
- Application server
- Load Balancer
- Middleware Servers
Now you have put all these three components into one physical server. And each of these components have different dependencies. So you have to install those dependencies to your single physical server.
Now the problems arise, when it comes to dependencies of each components there can be clashes. For an example imagine your application server needs jdk 8u181 and your middleware servers need jdk 7u131. So this is an issue you should not be having in your system. And also when it comes to ports there can be problems where different components trying to use the same port. So as you can see many issues have came to exist.
So we gotta find a solution. Some one may say ,
“Just use three computers for three servers..”
And yes , using more physical servers will solve the problems up to some point. Even though this solves some of the problems we wanted to be solved ,this solution comes with its own problems. Let’s have a look at those problems.
One main issue is the cost, both initial and maintenance cost is higher when it comes to more hardware. In a scenario when you’re not yet earning money from your app spending more money on hardware just to keep it running is not good. Even if your app or service pulling money towards you this is not actually “Cost Effective” in most cases.
Now imagine your app’s user base is growing. Your hardware can’t supply according to the demand. So what’s your solution ?
“Buy more hardware and upgrade”
So this is a time and money consuming task and you will have to buy more hardware whenever you want a performance upgrade or storage upgrade etc. Imagine you want to test new configuration and unfortunately things go wrong, then you will have to do big in damage control and find the suitable hardware and do the changes which is a hectic task.
VMs to the Rescue
Virtual Machines came to the picture with solutions for the problems mentioned above. First of all let’s see what “Virtual Machine” is.
As you can see in the above diagram VM actually is a “software boundary” given to a specific amount of processing power and PC. And each VM has its own operating system, binaries , libraries and a specific one app using the VM. The whole point of this Virtualization a machine is giving a isolated atmosphere to an App so it can breath in freely and exist. So the issues such as dependency clashes , port consumption issues cease to exist in VMs. And not just that when you need to upgrade your VM ( processing power , storage , ram ) you don’t have to buy more hardware, you can just provision the amount of resources you need in your specific VM as long as your Infrastructure can provide those resources.
Sounds Good right ?
Yes. But bear with me for a second.
As a species constantly evolving our needs evolve too ( exponentially ! ). Yes you are correct! we found problems in VMs too. So what’s next ? Now Let’s talk about the elephant in the room ;).
When we were using VMs we saw each of them has a Guest OS and its own resources dedicated to each one. So setting up a VM means giving installing a operating systems on the virtual resources allocated. So the it has to be booted to start the VM as same as a physical computer. And whenever you spin up a VM it will cost significant amount of RAM , CPU and storage just to keep it up idle. So as you can see Virtual machines has an overhead we have to deal with.
Containers comes to the picture with solutions for those problems in VMs.
Containers provide a logical packaging mechanism in which applications can be abstracted from the environment in which they actually run.
As described it seems like the same as VMs right ? Not really ! They are fundamentally different.
Let’s break this down. Virtual machines virtualize the hardware stack upon which they are provisioned, what containers do is do the virtualization at the operating system level. So what happens is multiple containers run atop the host OS kernel directly. Because of that like VMs containers doesnt need a guest OS which results containers to become way more lightweight and portable. So we dont have to worry about all overhead we have to handle in VMs. Containers are spun up when it is needed and then do their job and cease to exist. And when you need one again you spin up another container.
Containers are simple as that. But don’t get me wrong. There are so many things happening under the hood and so much more to containers that we have to dig in and investigate about. Don’t worry I’ll be writing more articles where I dive deep in to containers with you.
There are many container formats available. Such as Docker , rkt , singularity etc. Docker is by far the most popular container solution. Also Docker is widely supported in all major cloud providers.
Do we all need to move to Containers ?
No ! Just because containers have benefits comparing to VMs we can’t really do apples to apple comparison between VMs and Containers. There are scenarios where we need VMs and scenarios where we need containers. And also there are many enterprises even that I personally know who are not moved to container platform. And They run really well. If someone is going to use micro services architecture in their app’s development containers are ideal for them. Or if you’re trying to move in to container platform first you have to make your app container ready.
So what I discussed in this article is how we came towards to the point where we need Containers, What prevailed it. And I didn’t talk anything deeply technical about containers , VMs or anything. I hope you got a good idea about why people who use containers use them. So I ask you to keep in touch with my blog. I’ll be writing more articles about DevOps stuff , gaming , and whatever comes to my mind.