Edexcel International Advanced Level Computer Science, point 11.2.2
Definition
Virtualisation is creating a software version of something physical, most often several isolated "virtual" computers (or environments) running on one physical machine, so that the hardware is shared.
Two forms are covered here: virtual machines and containerisation.
Function and why needed
- One powerful server can run many separate systems, so hardware isn't left idle.
- Each system is isolated from the others, which is safer.
- Systems can be created, copied, moved and deleted quickly, without buying new hardware.
- It makes testing, development and cloud computing (12.4.1) practical.
Virtual machines (VMs)
A virtual machine is a software-based computer that behaves like a complete physical computer, with its own operating system (the guest OS).
- A hypervisor creates and manages the VMs, giving each a share of the CPU, memory, storage and network.
- Each VM thinks it has its own hardware. VMs are isolated: a crash or virus in one doesn't affect the others.
- A VM can run a different OS from the host (a Linux VM on a Windows PC).
Benefits of VMs
- Strong isolation and security.
- Run different operating systems on the same hardware.
- Better hardware use (less idle capacity), which saves money, space and power.
- Easy backup and recovery: a VM can be saved as a file, copied or restored.
- Safe testing (try risky software in a VM, then discard it).
- Can be moved between physical servers.
Drawbacks of VMs
- Each VM carries a full guest OS, so it uses a lot of memory and storage, and starts slowly (minutes).
- Performance overhead from the hypervisor.
- The physical host is a single point of failure: if it fails, all its VMs go down.
- Needs powerful hardware and licences for each guest OS.
a. Containerisation
Containerisation packages an application with everything it needs to run (its code, libraries and settings) into a lightweight, isolated unit called a container. All containers share the host operating system's kernel, instead of each having its own OS. (Docker is a well-known example.)
- A container image is a template (the packaged files). Running an image creates a container.
- Containers are isolated from each other (separate processes, files and network), but less strongly than VMs, as they share a kernel.
- A container starts in seconds, is small (megabytes), and can be copied to any machine that runs the container engine, with the same behaviour ("works on my machine" problems disappear).
Benefits of containers
- Lightweight: no guest OS, so less memory and disk.
- Fast to start and stop, and easy to scale (start 100 copies of a web server).
- Portable: the same container runs on a laptop, a server or the cloud.
- Consistent environments for development, testing and production.
- Efficient use of hardware: more containers than VMs on the same server.
- Suits microservices (an application split into small independent services).
Drawbacks of containers
- Weaker isolation: a flaw in the shared kernel can affect every container, so security needs care.
- All containers must be compatible with the host OS kernel (you can't run a Windows container directly on a Linux host).
- Managing many containers is complex (needs orchestration tools).
- Persistent data and networking need extra planning.
Virtual machines and containers compared
| Virtual machine | Container | |
|---|---|---|
| Includes | Full guest OS + application | Application + libraries only |
| Operating system | Own OS per VM | Shares the host OS kernel |
| Size | Gigabytes | Megabytes |
| Start time | Minutes | Seconds |
| Isolation | Stronger | Weaker (shared kernel) |
| Different OS possible? | Yes | No (same kernel type) |
| Performance overhead | Higher | Lower |
| Managed by | Hypervisor | Container engine |
| Best for | Strong isolation, different OSs, legacy applications | Many small, portable, scalable services |
Diagrams
You may need to interpret and complete diagrams of a containerised system and a virtual machine, so know the order of the layers (hardware, host OS (or hypervisor), engine or VMs, applications), and where the guest OS is (VM) and isn't (container).
Worked example
Task: a company wants to run 20 small web services on a few servers. Compare VMs and containers.
- With VMs: 20 guest operating systems, each using perhaps 1 to 2 GB of RAM just for itself, so 20 to 40 GB of overhead, and each takes minutes to start.
- With containers: one host OS and 20 small containers, each using only what its service needs (tens of MB). Starting more copies when traffic rises takes seconds, and the same container image runs on the developers' laptops and in production.
- Decision: containers suit this (many small services, scaling, portability). VMs would be better if the services needed different operating systems, or if the strongest possible isolation between customers was required.
Exam tip: the key difference is that a VM includes a full guest OS and is managed by a hypervisor, whereas containers share the host OS kernel. Link that to size, start-up time and isolation. For a diagram question, get the layers in order.
Check yourself
What is a hypervisor?
Software that creates and manages virtual machines, sharing the physical hardware between them.
What is the main difference between a virtual machine and a container?
A virtual machine includes its own full guest operating system. Containers share the host operating system's kernel and package only the application and its libraries.
Give two benefits of containers over virtual machines
Any two of: lighter and smaller; start in seconds; more per server; portable and consistent; easy to scale.
Give one advantage of a virtual machine over a container
Stronger isolation, and the ability to run a different operating system from the host.
Why does virtualisation save money?
Several systems share one physical machine, so less hardware, space and power are needed, and idle capacity is used.