Sunday, November 6, 2016

Today we discuss Containers versus Virtual Machines (vm).

As a cloud provider and consumer, we are aware that to the end user the computing power and storage matters more than how it is provisioned and where. The ease of requesting the compute, the cleanliness of instantiating and deleting the associated resource, the ability to migrate applications and services far out weigh any consideration of the vendor or the mechanism just so long as the performance, security and costs are comparable.

Essentially the provisioning of such compute is a result of partitioning some wholesale undivided resource whether it is at the ESX level or an instance level.  Each time a new resource is requested, a partition is made and the resource is provisioned. Partition do not interact with each other so we have isolation and this works well on shared resources.  The partitioning policy can depend on the size of the resource being cut , the availability and the load on the underlying fabric. A private cloud provider for example has several regional datacenters to distribute the volume of requests for new virtual machine instances.

Yet it is widely understood in computing world that we don't aggressively partition lest we shoot ourselves in the foot. Instead we are as lazy to partition the resources as and when the need arises.
As an example, we don't excessively partition our hard disk into many drives up front only to realize later that one drive is filled up while the other is relatively unused.  This brings up the importance of elasticity of the resource we partition. If we partition a datacenter into several virtual machines, is the datacenter elastic to more and more usage ? Yes for example, we can add ESX blades as appropriate in say a VMWare cloud. But what about a Linux container ? The same is true, if the current resource is exhausted, we provision elsewhere. However, the container is restricted to a vm and the vm may or may not be elastic.

Furthermore containers are governed by the quotas and limits of the underlying system to manage the shared resources. One of the reasons Solaris zones suffered from application migration considerations from the operating system consumers is that they kept running into application failures due to limits. Both linux containers and solaris zones must be understood as operating system features and not as standalone products for virtualization technologies.

That said linux containers have the advantage that they provide the same environment without the overhead of a separate kernel and hardware. This translates to lightning fast availability of an isolated shell as well as there reduction of failure points. Moreover hardware is not necessarily partitioned per virtual machine in any case. However, separtion of kernel does play significantly in terms of performance because the emulation is different from the real especially when compared to a standalone.

In addition, we now have integration with Open-stack for linux containers. The plugin allows the hosts to be compute nodes while the container takes on the workloads from the user.

#codingexercise
Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no two numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

        static int GetSum(List<int> nums, int start)
        {
            if (start >= nums.Count) return 0;
            int incl_sum = GetSum(nums, start + 2) + nums[start];
            int excl_sum = GetSum(nums, start + 1);
            return Math.Max(incl_sum, excl_sum);
        }

        static void Main(string[] args)
        {
            var nums = new List<int>() { 3, 2, 5, 7, 10, 9 };
            var nums1 = new List<int>() { 3, 2, 5, 10, 7 };
            var nums2 = new List<int>() { 3, 2, 7, 10 };
            var nums3 = new List<int>() { 3, 2 };
            var nums4 = new List<int>() { 3 };
            var nums5 = new List<int>() { };
            Console.WriteLine("Max = {0}", GetSum(nums, 0));
            Console.WriteLine("Max = {0}", GetSum(nums1, 0));
            Console.WriteLine("Max = {0}", GetSum(nums2, 0));
            Console.WriteLine("Max = {0}", GetSum(nums3, 0));
            Console.WriteLine("Max = {0}", GetSum(nums4, 0));
            Console.WriteLine("Max = {0}", GetSum(nums5, 0));
       }

Max = 19
Max = 15
Max = 13
Max = 3
Max = 3
Max = 0

No comments:

Post a Comment