Containers are a hot topic these days in the industry. It might be a completely new term for you or you might have heard someone talking about it, but you are not quite sure about the overall concept. In this post my aim is to make you aware of what Container is and how does it help us save on resources when it comes to application hosting.
Back in old days, we used to host an application on a server whose sole job was to provide the hosting environment. In cases where we had to scale up in order to get more performance as the business grew, we often ended up purchasing physical servers. These servers were utilized low on an average basis and had a significant amount of operating cost.
Then came the Hypervisors and Virtualization Technology which allowed us to have multiple Virtual Machines on a single server allowing us to host one application per Virtual Machine. This significantly increased the utilization of the physical server. This technology also served well as the basis of cloud computing.
However, As usual, we human beings are always looking for something better. So few intelligent brains in the industry studied the application hosting with Hypervisor Virtualization Model and came out with some facts which I’ll discuss in the next section as we look at this model.
Application Hosting with Hypervisor Virtualization Model
As shown in the picture above, we have a server with virtualization capability and some amount of resources like RAM, CPU and disk space. Let’s say we want to host four applications on this server. So, we created four virtual machines and allocated some amount of RAM, CPU and disk space from the server to each of these machines. Each of these machines needs its own separate Operating System. A fair amount of resources allocated to each virtual machine is consumed by the Operating System itself. Apart from this, we also need to purchase the licence for the Operating Systems. Not only that, these virtual machines need admin time in order to manage them and handle stuff like applying security patches and antivirus management etc. This might sound trivial for one virtual machine but imagine if we add up all of them and look at the cost then, definitely its something which we should think about.
Lets look at how Containers help us solve this problem.
Application hosting with Container model
As shown in the diagram above, we have a server with some amount of resources like RAM, CPU and disk space and one Operating System. We can slice that one operating system in to small containers which can host our applications. Each container can host an application in complete isolation from the other container hosting another application. Which means now have to pay only for one OS licence per server. We also save on system resources like RAM, CPU and disk space as there is only one Operating System. This creates more room for few more containers which can host more applications thus utilizing the server resources effectively.
So, Now you know how containers help us save on resources but still you might be wondering what is it?
What is Container?
Container is a native Operative System construct which provides light weight isolation. Linux Operating System has a concept of a Container which is comprised of few sub concepts like Namespaces, cgroup and Union File system.
Namespaces provide isolation for a user database, processes and IP address. So a container hosted on a Linux OS gets its own user database, process collection, networking stack and IP address.
cgroups in Linux OS acts like resource governors which makes sure that each container is getting its fair share of resources and none of them is exhausting on the resources.
The notion of Union File Systems allows us to mount several file systems at the same time with a read write layer on top. So each container gets a its own read-write view.
Together these concepts along with few more, creates the whole notion of a container.
A company and software framework called Docker harnessed these capabilities of Linux OS Container and created something called Docker Container. As part of it they unified the APIs and tooling for packaging applications and included everything at minimal level that is required to run an application inside a Docker Container. So this is how a Docker container holds the capability to host an application.
What about Windows OS?
As of now Windows Server Operating System does not have a concepts similar to Namespaces and cgroups. However, Microsoft has announced that future release of Windows Server OS will have something called Windows Server Container which will have similar capabilities like Linux OS Container.
I hope I could aid your understanding about containers through this post.