Often architects introduce virtualization to improve utilization of system and hardware resources.

Virtualization is a resource management technology. It can extract physical resources and separate them to maximize resource utilization. Today we are going to talk about traditional virtualization technology and container technology represented by Docker.

virtualization

Virtualization means running multiple virtual servers on one physical server. This Virtual server is also called a Virtual Machine (VM, Virtual Machine).

The original intention of virtualization is to reduce the number of physical servers and improve the utilization of server resources. Use virtualization technology to isolate physical servers into small virtual servers and provide deployment capabilities.

In short, virtualization can bring the following convenience to our work:

  • Reduce the number of physical servers
  • Improve resource utilization
  • Environmental isolation can be achieved
  • Resource isolation can be achieved
  • Virtual machines can be delivered in minutes
  • Vm accessories can be dynamically expanded
  • Vm compute nodes can be dynamically migrated

Virtualization technology

Hypervisors, also called Virtual Machine Monitor (VMM), are used to virtualize servers. A Hypervisor is not a specific piece of software but a general name of a class of software. For example, VMware, KVM, Xen, and Virtual Box are hypervisors.

VMware Workstation. To learn Linux, many people install WMware on a Windows system and create a Linux virtual machine.

Linux servers generally use KVM as a virtualization tool. KVM (kernel-based Virtual Machine) is a full-function virtualization solution for x86 hardware platforms running on Linux. Contains a loadable kernel module kVM. ko that provides and virtualizes core architecture and processor specification modules.

Virtualization Platform Architecture

Virtualization platforms have the following three architectures:

  • The local store

    A VM runs on a physical machine, and the VM disks reside on the disks of the physical machine

  • Centralized storage

    A physical machine running a VM whose disks are stored in shared storage. In the centralized storage architecture, if a host fails, the VM can run on another physical machine through the Settings of the platform, which realizes the dynamic drift of the VIRTUAL machine.

  • Distributed storage

    In distributed storage architecture, VM disks are distributed on all servers. In this architecture, also known as Computing and Storage Integration, VM disks are scattered into many pieces and distributed on all servers in a cluster to maximize storage capacity. Vm I/O is no longer limited by the disk capacity of a single vm, but takes advantage of the disk capacity of the entire cluster. This improves THE I/O capability of virtual machines and ensures data security through redundancy. The disadvantage of this architecture is that it relies heavily on network stability. Once the network is down, all VMS will be down.

High availability mechanism of virtualization platform

The high availability (HA) mechanism of a virtualization platform allows a VM to be switched to another physical vm after the physical vm is suspended. The prerequisite for high availability is that the physical machine is down, and there is no detection mechanism for vm internal faults. Therefore, it is an incomplete HIGH availability solution based on the following two objectives:

  • Vm compute nodes are migrated dynamically
  • Vm disks are migrated dynamically

Virtualization Principles

The emergence of the virtual machine is to make some big computing resources divided into many small resources and flexible deployment, follow the principle of divide and conquer is, if a virtual machine apply to the physical machine is in violation of the principle of the more than half of the resources, so it is better to direct use of physical machine to simply, so we in the use of virtualization in general should follow the following principles:

  • A VM occupies less than 40% of the resources of the host
  • Does not host disk IO intensive components (databases, message queues, search engines)
  • For a dual 2U server, the consolidation ratio is ideal at 1:4-1:10
  • CPU can be overallocated to a certain extent, up to about double
  • Memory generally cannot be overallocated

Docker container

After using virtualization for a while, there are some problems with it:

  • The system layer of VMS occupies resources of many physical servers. Therefore, the server resource utilization needs to be improved
  • When a VM service program needs to be migrated, the entire VM needs to be migrated. The migration process is complicated

To solve these problems, we introduced containers. Docker is the application container engine that creates containers. Containers are also virtualization, but it’s “lightweight” virtualization. Its purpose, like virtual machines, is to create an “isolated environment.” However, it is very different from virtual machines — virtual machines are operating system-level resource isolation, while containers are essentially process level resource isolation.

Virtualization VS Container

Compared with traditional virtual machines, Docker has obvious advantages, such as fast startup time, second level, and high resource utilization (a host can run thousands of Docker containers at the same time). In addition, it takes up a small amount of space, with virtual machines typically requiring several to tens of gigabytes, while containers require only megabytes or even kilobytes.

The performance and resource utilization gap between virtualization and containers can be seen in the following chart

The container arrangement

Docker can be used to easily create containers, but when the number of containers reaches a certain scale, it needs to be managed by choreography tools, namely, container life cycle management tools.

Container choreography tools provide the technology to schedule and manage clusters and provide the basic mechanism for extensibility of container-based applications. These tools use container services and orchestrate them to determine how containers interact with each other.

Docker Swarm, Kubernetes, Mesos, and Rancher are among many container choreography tools. Here is a picture to compare the features and advantages of these container choreography tools.

summary

Today, virtualization technology and container to do a simple review, virtualization and container original intention and purpose are to better improve resource utilization, as for the difference between the two must be remembered: virtual machine is operating system level resource isolation, and container is process level resource isolation.

For more exciting content, please go to the public account