Twenty servers or four?
A company has 20 old servers. Each one uses power, takes space and needs cooling. Most of them are busy for only an hour a day.
The company moves them into virtual machines. A virtual machine is a computer made of software. Now four strong computers do the work of twenty. Is it always a good idea? No. By the end of this lesson: I can weigh the benefits of a virtual environment against its drawbacks.
Key words
| Word | What it means | Example |
|---|---|---|
| Virtual machine | A computer made of software, running inside a real one. | A server in a file |
| Virtualisation | Making computers and their parts in software. | Four hosts, twenty servers |
| Disaster recovery | Getting systems working again after a big failure. | Start the VMs at another site |
| Carbon footprint | The carbon dioxide an activity makes. | Fewer machines, less power |
| Hypervisor | Software that makes and runs virtual machines. | The software that starts each guest |
| Snapshot | A saved copy of a virtual machine at one moment, to go back to. | Before a risky change |
| Overhead | Extra work done only to run the virtual layer. | CPU used by the hypervisor |
| Test environment | A safe copy of a system for trying changes before they go live. | A copy of the website |
| Container | A light, fast way to run one program in its own space, sharing the host's operating system. | A Docker container |
| Operating system | The main program that runs a computer. | Windows, Linux |
| Resilience | Keeping working, or recovering fast, when something fails. | Move a VM to another host |
| CPU | The processor, which runs a program's instructions. | The brain of a computer |
The cells students fill in are left blank in this preview.
Match the situation to the benefit
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Seven benefits
| Benefit | Why |
|---|---|
| Cost effective for large environments | Fewer machines to buy, house, power and cool |
| Easy to manage | One tool makes, copies, moves and removes many VMs |
| Resilience | A VM can move to another host if one host fails |
| Potentially lower carbon footprint | Fewer machines use less power. This depends on how well they are used. |
| Improved disaster recovery | A VM is a set of files, so it is easy to copy to another place and start again |
| Better testing environments | Make a copy, test, throw it away. Use snapshots to go back. |
| Education and training | Each learner has a safe machine of their own |
The cells students fill in are left blank in this preview.
Three drawbacks
| Drawback | Why |
|---|---|
| Extra hardware load | The hypervisor and each guest operating system use CPU, memory and storage. The host must be strong. |
| Slower execution | The program runs more slowly, because an extra layer sits between it and the hardware |
| A false picture of performance | A test in a VM may not match the real machine, because VMs share hardware and the layer adds delay |
The cells students fill in are left blank in this preview.
Quick check: good or bad?
Have a go
Quick check: good or bad?
4 questionsGood point or bad point?
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Worked example: is it cheaper?
Here are the numbers for the company in the hook. They are made up for this example.
Each old server costs 600 pounds a year to run: power, space and cooling. A strong host costs 1500 pounds a year to run. One host holds 5 virtual machines.
Worked example: the sums
| Step | Sum | Answer |
|---|---|---|
| Hosts needed for 20 servers | 20 divided by 5 (20 / 5) | 4 hosts |
| Cost of the old way | 20 times 600 (20 x 600) | 12000 pounds |
| Cost of the new way | 4 times 1500 (4 x 1500) | 6000 pounds |
| Saving each year | 12000 take away 6000 (12000 - 6000) | 6000 pounds |
The cells students fill in are left blank in this preview.
Try it: the saving
old_servers = 20
old_cost = 600
vms_per_host = 5
host_cost = 1500
hosts = old_servers // vms_per_host
old_total = old_servers * old_cost
new_total = hosts * host_cost
print("Old way:", old_total, "New way:", new_total)
print("Saving each year:", old_total - new_total)
# Change host_cost to 3000. Is it still cheaper?
Make a free account to save your work and track your progress.
Your turn: hosts and savings
Write two functions.
- hosts_needed(vms, vms_per_host) gives back how many hosts you need. If some VMs are left over, you need one more host. For example, 21 VMs at 5 for each host: 21 // 5 is 4, and 21 % 5 is 1 left over. So you need 5 hosts.
- yearly_saving(old_count, old_cost, new_count, new_cost) gives back the money saved in a year: the old total take away the new total.
Press Run Tests to check.
def hosts_needed(vms, vms_per_host):
# How many hosts do we need? Each host holds vms_per_host virtual machines.
# 21 virtual machines at 5 for each host need 5 hosts, because 4 hosts hold only 20.
return 0
def yearly_saving(old_count, old_cost, new_count, new_cost):
# The old way: old_count machines, each costing old_cost a year.
# The new way: new_count hosts, each costing new_cost a year.
# Give back how much money is saved in a year.
return 0
Make a free account to save your work, or press Start lab to work through the whole lesson.
Extra: A lighter cousin: containers
A container runs one program in its own space. It shares the operating system of the host.
So it starts in seconds and uses less memory than a VM. The isolation is not as strong as a VM, because the operating system is shared.
Extra: See three containers
docker ps -aA command for the lesson’s lab terminal. It is shown here and not run.
Extra: Read what one container said
docker logs workerA command for the lesson’s lab terminal. It is shown here and not run.
Extra: What the lab shows
Note
Three containers run side by side. One of them has stopped, and its log says why. A VM would need a whole operating system for each one. The containers share one.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go