Virtualization is a technology that allows a single computer to act as multiple computers, or multiple computers to appear as a single computer.
This article provides a technical overview of the former approach—partitioning a single physical machine into multiple environments—by examining three major virtualization models.
1. Hypervisor-Based Virtualization
A virtualization model where a dedicated software layer (the hypervisor) is installed directly on the physical hardware to run multiple guest operating systems.
- Key Characteristic: Highly efficient and fast because it eliminates the overhead of a host operating system.
- Practical Application (WSL2): Enabling this feature installs Hyper-V directly onto the physical hardware, allowing Windows and Linux to run concurrently.
- Operational Mechanics: While Linux appears to run inside Windows, they are actually separate environments. The Windows PowerShell or VSCode terminal functions essentially as a viewer for WSL2, operating similarly to an SSH connection.
2. Hosted Virtualization
A model where a virtualization application runs on top of a host operating system (e.g., Windows) to boot and manage separate guest operating systems (e.g., Linux).
- Primary Objective: Used by developers to build isolated, disposable testing environments without modifying or contaminating the host operating system.
- Disadvantage: Significant resource overhead due to running an entire operating system on top of another.
3. Containerization
An architecture that shares the host operating system kernel among isolated user-space instances (containers), rather than booting separate guest operating systems.
- Primary Objective: Used to run specific tool versions (e.g., Node.js) or variable environment configurations efficiently using container runtimes like Docker.
- Core Distinction from Hosted Virtualization:
- Hosted Model: Boots an entire, separate operating system (high resource consumption).
- Container Model: Leverages the single host operating system to run isolated application environments (low resource consumption).
Conclusion
Unless a different operating system kernel is explicitly required, containerization is the preferred choice in modern development and QA testing due to its lightweight performance.