1. Introduction
There are a range of techniques available to deploy the applications to production and choosing the right strategy is an important decision for a particular use case. In this article, we will focus mainly on choosing a right deployment model for our in-house built applications.
2. Deployment Use Case
Let us consider two applications, File Downloader and File Processor. The functional details are described in the below table:
Note that we have one Physical Server with 100GB HDD, 16 GB RAM and 4 Core Processor.
Our goal is to deploy both applications to this server for optimal utilization of infrastructure and better performance.
3. Deployment Options
The below diagram shows various deployment options available for us.
3.1 Single Server
In this option, both the applications were deployed in a single available server.
3.2 Virtual Machine
In this option, we will split the available server into two virtual machines using Hypervisor. Hypervisor, also known as virtual machine monitor/supervisor, is a process that creates and runs virtual machines. A hypervisor allows one host computer to support multiple guest VMs by virtually sharing its resources, like memory and processes.
There are two types of hypervisors as below:
Type 1 - Run directly on the system hardware, example, Hyper Kit for MacOS, Hyper-V for Windows and KVM for Linux.
Type 2 (Hosted) - Run on a host operating system that provides virtualization services. Example: VirtualBox and VMWare
The above diagram utilizes Type 1 Hypervisor.
Each VM will have guest operating system and we will plan to deploy the File Downloader in VM1 and File Processor in VM2.
Since File Downloader app consumes more memory, we need to allocate more memory limit for VM1 as compared to VM2.
Since File Processor app consumes more processor time, we need to allocate more CPU core limit for VM2 as compared to VM1.
In this way, we can optimally utilize the server resources.
3.3 Containers
In this option, we will install the Container Engine (for example, Docker Engine) on top of the existing operating system. We will create two containers to host File Downloader and File Processor apps.
Since File Downloader app consumes more memory, we need to allocate more memory limit for Container 1 as compared to Container 2.
Since File Processor app consumes more processor time, we need to allocate more CPU core limit for Container 2 as compared to Container 1.
In this way, we can optimally utilize the server resources.
4. Resource Utilization Comparison
The below diagram shows the resource utilization chart for all three deployment options which we have discussed so far.
Based on the utilization chart, we have noticed the below observations:
- Single server deployment offered poor performance as both applications are sharing the same resources.
- Both virtual machine and container deployment offered nearly equal performance.
- More resources are consumed by virtual machine deployment.
- Both single server and container deployment offered nearly equal resource utilization.
5. Comparison of Virtual Machine & Container
The below table shows the comparison between Virtual Machine and Container based deployments:
SL # | Virtual Machine | Container |
1 | Heavy weight with limited performance | Light weight with improved performance |
2 | Each VM runs in its own OS and can’t run more VMs on an average server | All Containers share the same kernel of the host and can run more containers on an average server |
3 | Virtual machines take few minutes to start | Containers take few milliseconds to start |
4 | Wastage of resources – Requires more space and memory for each VM (terms of GB) | Saves resources - Requires less space and memory for each Container (terms of MB) |
5 | Hardware-level virtualization and requires more OS license and cost | OS virtualization and requires only one OS license and reduced cost |
6 | VM is running instance of physical files (. VMX and. VMDK) | Container is running instance of Container Image |
7 | Each VM will have its own virtual network adapter, IP and Ports | Each Container will have its own virtual network adapter, IP and Ports |
8 | Virtual machines are scalable and come with dedicated disk space, core and memory allocations | Containers are scalable and come with dedicated disk space, core and memory allocations |
9 | Processes in one VM can’t be seen from another VM | Processes in one Container can’t be seen from another Container |
10 | Each VM will have its own root file system | Each Container will have its own root file system |
Points of Interest
Based on the various deployment options, resource utilization chart and comparison between VM, Containers, for our use case, Container based deployment option gave us the cost-effective solution with good performance.
In the next article, I will introduce Docker Containers with detailed deployment architecture overview.
History
- 19th February, 2019: Initial version