CMP424 Cloud Computing and Virtualization

Cloud Computing and VirtualizationUnit 411 min read

Hypervisors: Types, Functions & Architecture

Unit 4 of Cloud Computing and Virtualization explores hypervisors—the backbone of virtualization—covering their types (Type-1 vs. Type-2), core functions (resource allocation, isolation, scheduling), architecture (microkernel vs. monolithic), and real-world implementations like VMware ESXi and Microsoft Hyper-V. Includ

What is a Hypervisor?

A hypervisor (or Virtual Machine Monitor, VMM) is software/firmware that creates, manages, and runs virtual machines (VMs) on a single physical host. It abstracts hardware resources (CPU, RAM, storage, network) and allocates them to VMs while ensuring isolation and security.

Why Use Hypervisors?

  • Resource Efficiency: Run multiple OSes on one machine (e.g., Windows + Linux on a single server).
  • Isolation: Crash one VM without affecting others (critical for cloud services).
  • Scalability: Dynamically allocate resources (e.g., auto-scaling in AWS).
  • Cost Savings: Reduce hardware costs by consolidating workloads.

Types of Hypervisors

Hypervisors are classified based on their placement in the system architecture. The two main types are:

1. Type-1 (Bare-Metal) Hypervisor

  • Runs directly on hardware (no host OS).
  • Faster performance (lower overhead).
  • Used in enterprise/data centers (e.g., VMware ESXi, Microsoft Hyper-V, Xen).
  • Example: A cloud provider like Ncell’s data center uses Type-1 hypervisors to host thousands of VMs for their services.
graph TD
    A["Physical Hardware"] --> B["Type-1 Hypervisor"]
    B --> C["VM 1 (OS: Ubuntu)"]
    B --> D["VM 2 (OS: Windows Server)"]
    B --> E["VM 3 (OS: Linux)"]

2. Type-2 (Hosted) Hypervisor

  • Runs on top of a host OS (e.g., Windows, Linux).
  • Slower (extra layer of abstraction).
  • Used for development/testing (e.g., Oracle VirtualBox, VMware Workstation).
  • Example: A Nepalese developer testing a web app on both Windows and Linux VMs using VirtualBox.
graph TD
    A["Host OS (Windows/Linux)"] --> B["Type-2 Hypervisor"]
    B --> C["VM 1 (OS: Ubuntu)"]
    B --> D["VM 2 (OS: macOS)"]
Feature Type-1 Hypervisor Type-2 Hypervisor
Performance High (direct hardware access) Low (depends on host OS)
Use Case Data centers, cloud providers Development, testing, education
Examples VMware ESXi, Microsoft Hyper-V, Xen VirtualBox, VMware Workstation
Security More secure (no host OS vulnerabilities) Less secure (host OS is a risk)

How Hypervisors Work: Core Functions

A hypervisor performs three key tasks:

1. Hardware Abstraction

  • Virtualizes hardware (CPU, RAM, storage, network) so VMs think they have dedicated resources.
  • Uses emulation (e.g., running ARM code on x86 via QEMU) or paravirtualization (guest OS modified for efficiency).
  • Example: A Daraz server running multiple e-commerce VMs on a single physical machine.

2. Resource Allocation & Scheduling

  • CPU Scheduling: Uses algorithms like Round Robin, Priority Scheduling to share CPU time.
  • Memory Management: Allocates RAM dynamically (e.g., ballooning in VMware to reclaim memory).
  • Storage Virtualization: Uses LUN masking, SAN/NAS to provide storage to VMs.
  • Network Virtualization: Assigns virtual NICs (vNICs) and manages traffic via vSwitches.
stateDiagram-v2
    [*] --> Idle
    Idle --> Running: "CPU Allocated"
    Running --> Idle: "Time Slice Ends"
    Running --> Paused: "Low Priority"
    Paused --> Running: "High Priority"

3. Isolation & Security

  • Memory Isolation: Prevents VMs from accessing each other’s RAM.
  • CPU Pinning: Binds VMs to specific cores for performance.
  • Security Features:
    • Sandboxing (e.g., Docker containers).
    • Encryption (e.g., VMware’s vTPM for secure boot).
  • Example: Nepal Rastra Bank uses hypervisor isolation to secure financial transactions across VMs.

Hypervisor Architecture

Hypervisors can be designed in two ways:

1. Microkernel Architecture

  • Minimal core (only essential functions like scheduling, memory management).
  • Device drivers and services run as separate modules.
  • Pros: More stable (crash in one module doesn’t affect others).
  • Cons: Slightly slower due to inter-module communication.
  • Example: Xen (used in AWS for high availability).
classDiagram
    class Hypervisor {
        +Core Scheduling
        +Memory Management
    }
    class Module1 {
        +Device Driver
    }
    class Module2 {
        +Network Service
    }
    Hypervisor --> Module1
    Hypervisor --> Module2

2. Monolithic Architecture

  • All components (scheduling, I/O, memory) in a single kernel.
  • Pros: Faster performance (no inter-module overhead).
  • Cons: Less stable (crash in one component affects others).
  • Example: VMware ESXi (used in enterprise data centers).
graph TD
    A["Monolithic Hypervisor"] --> B["CPU Scheduler"]
    A --> C["Memory Manager"]
    A --> D["I/O Subsystem"]
Architecture Pros Cons Examples
Microkernel Stable, modular Slower Xen, KVM (Linux)
Monolithic Faster, simpler Less stable VMware ESXi, Hyper-V

Real-World Applications of Hypervisors

1. Cloud Computing (AWS, Google Cloud, NTC’s Cloud Services)

  • How it works: AWS uses Xen and KVM hypervisors to run thousands of VMs for services like EC2 (Elastic Compute Cloud).
  • Example: When you use eSewa to pay bills online, the backend servers are likely running on hypervisor-managed VMs for scalability.

2. Data Centers & Enterprise IT (Ncell, Nabil Bank, NEPSE)

  • How it works: Banks like Nabil Bank use VMware ESXi to host multiple VMs for different departments (HR, Finance, Customer Service) on a single physical server.
  • Example: During NEPSE trading hours, stock exchange servers use hypervisors to handle high traffic without downtime.

3. Development & Testing (Local Machines, Universities)

  • How it works: Developers use VirtualBox to test software on different OSes (e.g., a Pathao driver app tested on Android + iOS VMs).
  • Example: A PU student testing a Python app on both Windows and Linux VMs without buying separate hardware.

Worked Example: Hypervisor in a Bank’s Loan Processing System

Scenario: A bank like Global IME Bank processes loan applications 24/7. They use a Type-1 hypervisor (VMware ESXi) to run:

  • VM 1: Customer portal (Windows Server).
  • VM 2: Loan processing (Linux).
  • VM 3: Database (SQL Server).

Steps:

  1. Resource Allocation:

    • VM 1 (Customer Portal) gets 4 CPU cores, 8GB RAM.
    • VM 2 (Loan Processing) gets 8 CPU cores, 16GB RAM (higher priority during peak hours).
    • VM 3 (Database) gets SSD storage, 32GB RAM.
  2. Isolation:

    • If the customer portal crashes, loan processing continues unaffected.
  3. Scalability:

    • During Diwali season, the bank clones VM 1 to handle extra traffic.

Mermaid Diagram:

sequenceDiagram
    participant User
    participant VM1 as Customer Portal (VM)
    participant VM2 as Loan Processing (VM)
    participant Database as SQL Server (VM)
    User->>VM1: Logs in
    VM1->>VM2: Validates loan
    VM2->>Database: Queries data
    Database-->>VM2: Returns records
    VM2-->>VM1: Approves/Rejects
    VM1-->>User: Displays result

Hypervisor Type Key Features Use Case
VMware ESXi Type-1 High performance, vMotion (live migration) Enterprise data centers
Microsoft Hyper-V Type-1 Integrated with Windows Server Microsoft cloud environments
Xen Type-1 Open-source, used in AWS Cloud providers
KVM (Kernel-based VM) Type-1 Linux-based, high security Linux servers, OpenStack
VirtualBox Type-2 Free, easy for development Local testing, education
VMware Workstation Type-2 Advanced features for developers Software testing

Advantages & Disadvantages of Hypervisors

Advantages

✅ Cost Savings: Fewer physical servers needed. ✅ High Availability: Live migration (e.g., VMware vMotion) for zero downtime. ✅ Disaster Recovery: Snapshots and backups of VMs. ✅ Flexibility: Run different OSes on one machine. ✅ Security: Isolation prevents malware from spreading across VMs.

Disadvantages

❌ Complexity: Managing multiple VMs requires expertise. ❌ Performance Overhead: Type-2 hypervisors slow down the host. ❌ Licensing Costs: Enterprise hypervisors (e.g., VMware) are expensive. ❌ Single Point of Failure: If the hypervisor crashes, all VMs go down.


Exam Tip

What to Focus On

  1. Differentiate Type-1 vs. Type-2 hypervisors (performance, use cases, examples).
  2. Explain how hypervisors allocate resources (CPU, RAM, storage, network).
  3. Compare microkernel vs. monolithic architecture (stability vs. speed).
  4. Real-world examples:
    • Cloud providers (AWS, NTC) use Type-1 hypervisors.
    • Banks (Nabil, Global IME) use VMware ESXi for security.
    • Developers use VirtualBox for testing.
  5. Diagrams:
    • Draw hypervisor architecture (layers).
    • Show VM lifecycle (creation, suspension, deletion).
    • Illustrate resource allocation (CPU, RAM sharing).

Common Exam Questions

  • "How does a Type-1 hypervisor differ from a Type-2?"
  • "Explain the role of a hypervisor in cloud computing."
  • "What are the security benefits of hypervisor isolation?"
  • "Compare Xen and VMware ESXi in terms of architecture."

In the Real World

  1. eSewa & Khalti (Digital Payments)

    • Idea Used: Type-1 Hypervisors (KVM/Xen)
    • How: eSewa’s backend servers run on scalable VMs managed by hypervisors to handle millions of transactions during Dashain/Tihar. The hypervisor ensures isolation so a payment failure in one VM doesn’t crash the entire system.
  2. Ncell & NTC (Telecom Services)

    • Idea Used: Live Migration (VMware vMotion)
    • How: During peak hours, Ncell dynamically moves VMs between physical servers using hypervisor-based live migration to prevent overload. This ensures 99.99% uptime for calls and internet.
  3. Daraz & Pathao (E-Commerce & Ride-Hailing)

    • Idea Used: Containerization + Hypervisors
    • How: Daraz uses Docker containers (lightweight VMs) on hypervisors to deploy microservices (e.g., order processing, payment gateway). Pathao uses hypervisors to scale ride-matching servers during festival traffic surges.

Key Takeaways

  • Hypervisors are the engine of virtualization, enabling cloud computing and resource efficiency.
  • Type-1 (bare-metal) is for enterprise, Type-2 (hosted) is for development.
  • Resource allocation, isolation, and scheduling are core functions.
  • AWS, banks, and telecoms rely on hypervisors for scalability and security.
  • Exam focus: Compare types, explain architecture, and give real-world cloud examples.

Based on the PU BE Computer (PU) syllabus for Cloud Computing and Virtualization (CMP424), unit 4.

Discussion

Loading…