Showing raw Markdown: the renderer could not load.
## Goal
Act as the IT adviser of a small organisation. First decide who looks after each part of a system in each service model. Then choose the right model for four workloads. Finally, run a short Python script that shows when renting servers is cheaper than buying them, and when it isn't.
## Objectives
- Say who manages each layer (you or the provider) in on-premises, IaaS, PaaS and SaaS.
- Choose a service model and a deployment model for a workload, and give the reason.
- Compare the monthly cost of owning servers with renting them, for a busy-then-quiet load and for a steady load.
## Prerequisites
- Python 3.9 or later (`python3 --version`). You only run a script; you don't need to know Python.
- A terminal and a text editor.
- No cloud account, no payment details and no network access.
- [The Cloud Fundamentals lesson](lesson.md) of this module.
> [!WARNING]
> Nothing in this lab touches a real cloud. All prices are **invented, round numbers for teaching**, not any provider's price list. Don't use them for a real purchase.
## Architecture
<figure class="diagram" style="--dg-w: 1000px"><svg xmlns="http://www.w3.org/2000/svg" class="dg" viewBox="0 0 1000 360" width="1000" height="360" role="img" aria-labelledby="cloud-lab-architecture-title cloud-lab-architecture-desc" font-family="Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif" xml:lang="en">
<title id="cloud-lab-architecture-title">Lab scenario: placing four workloads and pricing them</title>
<desc id="cloud-lab-architecture-desc">On the left, the invented organisation Riverside Vet Group with four workloads: staff email and calendar, an online booking portal, a practice-management app and photo thumbnails. An arrow labelled you decide leads to three steps on the right: step 1, who manages what, answered on paper; step 2, choose a model for each workload, answered on paper; and steps 3 and 4, the script cost.py in the folder ~/cloud-lab-01, which compares owning servers with renting them.</desc>
<rect class="dg-bg" x="0.5" y="0.5" width="999" height="359" rx="16" fill="#ffffff" stroke="#e3e3dd"/>
<g class="dg-l1"><rect class="dg-tint" x="20" y="20" width="400" height="320" rx="16" fill="#f0f6f9" stroke="#9ac3d9" stroke-width="1.2" stroke-dasharray="6 5"/>
<g class="dg-icon" transform="translate(36 33) scale(0.7500)" fill="none" stroke="#0369a1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z"/><path d="M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2"/><path d="M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2"/><path d="M10 6h4"/><path d="M10 10h4"/><path d="M10 14h4"/><path d="M10 18h4"/></g>
<text x="62" y="47" font-size="13" class="dg-ink" fill="#0369a1" font-weight="700">Riverside Vet Group (invented)</text></g>
<g class="dg-l2"><rect class="dg-tint" x="520" y="20" width="460" height="320" rx="16" fill="#f1f7f3" stroke="#a1ccb1" stroke-width="1.2" stroke-dasharray="6 5"/>
<g class="dg-icon" transform="translate(536 33) scale(0.7500)" fill="none" stroke="#15803d" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g>
<text x="562" y="47" font-size="13" class="dg-ink" fill="#15803d" font-weight="700">Your decisions</text></g>
<rect class="dg-card" x="40" y="60" width="360" height="62" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l1"><g class="dg-icon" transform="translate(56 76) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"/><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M10 9H8"/><path d="M16 13H8"/><path d="M16 17H8"/></g></g>
<g class="dg-l1"><text x="98" y="97" font-size="14" class="dg-ink" fill="#0369a1" font-weight="700">Staff email and calendar</text></g>
<rect class="dg-card" x="40" y="130" width="360" height="62" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l1"><g class="dg-icon" transform="translate(56 146) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/></g></g>
<g class="dg-l1"><text x="98" y="167" font-size="14" class="dg-ink" fill="#0369a1" font-weight="700">Online booking portal</text></g>
<rect class="dg-card" x="40" y="200" width="360" height="62" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l1"><g class="dg-icon" transform="translate(56 216) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="8" x="2" y="2" rx="2"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 6h.01"/><path d="M6 18h.01"/></g></g>
<g class="dg-l1"><text x="98" y="237" font-size="14" class="dg-ink" fill="#0369a1" font-weight="700">Practice-management app</text></g>
<rect class="dg-card" x="40" y="270" width="360" height="62" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l1"><g class="dg-icon" transform="translate(56 286) scale(1.2500)" fill="none" stroke="#0369a1" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></g></g>
<g class="dg-l1"><text x="98" y="307" font-size="14" class="dg-ink" fill="#0369a1" font-weight="700">Photo thumbnails</text></g>
<rect class="dg-card" x="540" y="60" width="420" height="80" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><g class="dg-icon" transform="translate(556 76) scale(1.2500)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/></g></g>
<g class="dg-l2"><text x="598" y="97" font-size="14" class="dg-ink" fill="#15803d" font-weight="700">Step 1: who manages what?</text></g>
<text x="558" y="128" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">you or the provider, on paper</text>
<rect class="dg-card" x="540" y="152" width="420" height="80" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l2"><g class="dg-icon" transform="translate(556 168) scale(1.2500)" fill="none" stroke="#15803d" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></g></g>
<g class="dg-l2"><text x="598" y="189" font-size="14" class="dg-ink" fill="#15803d" font-weight="700">Step 2: choose a model</text></g>
<text x="558" y="220" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">SaaS, FaaS, PaaS or IaaS, on paper</text>
<rect class="dg-card" x="540" y="244" width="420" height="80" rx="12" fill="#ffffff" stroke="#cfcfc8"/>
<g class="dg-l3"><g class="dg-icon" transform="translate(556 260) scale(1.2500)" fill="none" stroke="#b45309" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16"/></g></g>
<g class="dg-l3"><text x="598" y="281" font-size="14" class="dg-ink" fill="#b45309" font-weight="700">Steps 3-4: cost.py</text></g>
<text x="558" y="312" font-size="13" class="dg-muted" fill="#5c5c68" font-weight="500">~/cloud-lab-01: own or rent?</text>
<g class="dg-l1"><path class="dg-stroke" d="M422 180H512" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l1"><path class="dg-stroke" d="M507 174l8 6-8 6" stroke="#0369a1" stroke-width="2.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></g>
<g class="dg-l1"><rect class="dg-bg-plain" x="425.8" y="146" width="82.4" height="24" rx="12" fill="#ffffff"/><text x="467" y="162.5" font-size="11.5" class="dg-ink" fill="#0369a1" font-weight="600" text-anchor="middle">you decide</text></g>
</svg></figure>
*Figure 1. Steps 1 and 2 are thinking exercises; steps 3 and 4 run one small script.*
## Steps
### Step 1 — Who manages what? (8 min)
The lesson showed that the service model decides who looks after each layer. Test yourself. On paper or in a text file, answer each question with **you** (the customer) or **provider**:
1. In **IaaS**, who installs security updates on the virtual machine's operating system?
2. In **IaaS**, who replaces a broken disk in the physical server?
3. In **PaaS**, who keeps the runtime (for example, the Python version) up to date?
4. In **PaaS**, who fixes a bug in the application code?
5. In **SaaS** (for example, a webmail service), who fixes a bug in the application?
6. In **SaaS**, who decides which employees can read the company's mailboxes?
Try them all before opening the answers.
<details>
<summary>Show the answers</summary>
| # | Answer | Why |
|---|---|---|
| 1 | You | In IaaS you rent a virtual machine; everything from the operating system up is yours. |
| 2 | Provider | The hardware and the datacentre are always the provider's in a cloud model. |
| 3 | Provider | In PaaS you bring only your code; the platform underneath is the provider's. |
| 4 | You | It's your code. |
| 5 | Provider | In SaaS you use a finished application; the provider builds and fixes it. |
| 6 | You | Data and access control stay with you in **every** model. |
The full picture, as in the lesson:
| Layer | On-premises | IaaS | PaaS | SaaS |
|---|---|---|---|---|
| Data and access control | You | You | You | You |
| Application | You | You | You | Provider |
| Operating system and runtime | You | You | Provider | Provider |
| Servers, storage and datacentre | You | Provider | Provider | Provider |
The further right you go, the less you manage. The first row never changes.
</details>
### Step 2 — Choose a model for each workload (10 min)
**The scenario.** Riverside Vet Group is an invented organisation: 4 veterinary clinics, 60 staff and one IT person. The board wants to "move to the cloud" and asks you about four workloads:
| Workload | Facts |
|---|---|
| Staff email and calendar | Everyone needs it. Nothing special. Nobody wants to run a mail server. |
| Online booking portal | A web application the group's own developer wrote. Busy in the mornings, almost idle at night. |
| Practice-management app | Bought from a vendor that only supports it on one specific Windows Server version. It can't be changed. |
| Photo thumbnails | When a pet photo is uploaded, a small version must be made. A few seconds of work, then nothing for a while. |
For each workload, ask these three questions **in order** and stop at the first "yes":
1. Can we just use a finished product? → **SaaS**
2. Is it our own code that only runs for a moment when something happens? → **FaaS** · Is it our own code that runs all the time? → **PaaS**
3. Do we need control of the operating system? → **IaaS**
Write down your choice and one sentence of reason for each workload.
<details>
<summary>Show one good set of answers</summary>
| Workload | Model | Reason |
|---|---|---|
| Staff email and calendar | SaaS | A common need with good finished products; the provider runs and patches everything. |
| Online booking portal | PaaS | Our own code, running all day; we don't want to patch servers. |
| Practice-management app | IaaS | The vendor requires a specific operating system, so we need to control it. |
| Photo thumbnails | FaaS | Short tasks that start when a photo arrives; we pay only while it runs. |
Other answers can be right if the reason is good. For example, the booking portal on IaaS works too, but then the team must patch the servers.
</details>
**One more decision: the deployment model.** The group also keeps X-ray images that, by law, must stay inside the country. Does that force a private cloud?
<details>
<summary>Show the answer</summary>
Not necessarily. The law requires a **location** inside the country, not your own building. A public cloud region inside the country meets it. A private cloud also does, but costs more to build and run. Read what a rule really requires before choosing.
</details>
### Step 3 — Compare owning and renting (10 min)
The booking portal is busy for two hours each morning and quiet the rest of the day. Should the group buy servers or rent them? Create a folder and a small script:
```bash
mkdir ~/cloud-lab-01
cd ~/cloud-lab-01
cat > cost.py <<'EOF'
# Owning servers versus renting them, for one month.
# All prices are invented, round numbers for teaching.
OWN_PER_SERVER_MONTH = 100 # buying a server, spread over its life, plus power: EUR per month
RENT_PER_SERVER_HOUR = 0.20 # renting one similar server: EUR per hour
DAYS = 30
def compare(name, busy_servers, busy_hours, quiet_servers):
quiet_hours = 24 - busy_hours
server_hours = (busy_servers * busy_hours + quiet_servers * quiet_hours) * DAYS
own = busy_servers * OWN_PER_SERVER_MONTH # you must own enough servers for the busiest hour
rent = server_hours * RENT_PER_SERVER_HOUR # you rent only what each hour needs
print(f"{name}: own {own:.0f} EUR, rent {rent:.0f} EUR -> cheaper: {'rent' if rent < own else 'own'}")
compare("Booking portal", busy_servers=10, busy_hours=2, quiet_servers=2)
compare("Steady service", busy_servers=6, busy_hours=24, quiet_servers=6)
EOF
python3 cost.py
```
Expected output:
```text
Booking portal: own 1000 EUR, rent 384 EUR -> cheaper: rent
Steady service: own 600 EUR, rent 864 EUR -> cheaper: own
```
How the numbers come out:
- **Booking portal.** It needs 10 servers for 2 hours a day and 2 servers for the other 22. If you **own**, you must buy enough for the busiest moment: 10 servers × 100 EUR = 1,000 EUR a month, even though 8 of them sit idle most of the day. If you **rent**, you pay only for what each hour uses: (10 × 2 + 2 × 22) = 64 server-hours a day × 30 days × 0.20 EUR = 384 EUR. Renting wins.
- **Steady service.** It needs 6 servers all day, every day. Owning costs 6 × 100 = 600 EUR. Renting costs 6 × 24 × 30 × 0.20 = 864 EUR. With no quiet hours to save on, the owned servers are always busy, and **owning wins**.
This is the CapEx-versus-OpEx trade-off of the lesson: buying (CapEx) means paying for the peak all the time; renting (OpEx) follows the load.
### Step 4 — Change a price and predict (5 min)
Suppose the rental price drops to 0.10 EUR per hour. Before running anything, guess: which of the two answers will change?
Open `cost.py` in your text editor and change this line:
```text
RENT_PER_SERVER_HOUR = 0.20
```
to:
```text
RENT_PER_SERVER_HOUR = 0.10
```
Save the file and run it again:
```bash
python3 cost.py
```
Expected output:
```text
Booking portal: own 1000 EUR, rent 192 EUR -> cheaper: rent
Steady service: own 600 EUR, rent 432 EUR -> cheaper: rent
```
Was your guess right? The booking portal was already cheaper to rent. The steady service changes: at half the price, renting it all day (432 EUR) now costs less than owning (600 EUR). The answer to "buy or rent?" depends on two things: **how much the load changes** and **the prices**. Check both before deciding.
## Verification
Put the price back to `0.20`, save, and run the script once more:
```bash
python3 cost.py
```
You pass if the output matches Step 3: renting is cheaper for the booking portal and owning is cheaper for the steady service.
## Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| `python3: command not found` | Python isn't installed, or it is called `python` | Install Python 3.9 or later; on Windows, use WSL2 or install it from python.org and run `python` instead of `python3` |
| `IndentationError` or `SyntaxError` | A line lost its spaces at the start, or was pasted only in part | Delete `cost.py` and run the whole Step 3 block again |
| `mkdir: cannot create directory ... File exists` | You already ran Step 3 once | Fine: just run `cd ~/cloud-lab-01` and continue |
| The numbers differ from the lab | A price in `cost.py` is still changed | Set `RENT_PER_SERVER_HOUR = 0.20` and `OWN_PER_SERVER_MONTH = 100` again |
## Challenge (optional)
1. The booking portal launches a marketing campaign and is now busy for 12 hours a day instead of 2. Change `busy_hours=2` to `busy_hours=12` for the booking portal and guess the result before running it.
2. Add a third line for your own example, such as a school website that is busy only during term time, and decide whether to own or rent.
## Cleanup
The lab created one folder in your home directory and nothing else. Remove it:
```bash
cd ~
rm -r ~/cloud-lab-01
```
## What you learned
- Who manages what depends on the service model, but your data and who can access it are always your responsibility.
- To choose a service model, ask in order: is there a finished product (SaaS)? Is it our own code (FaaS or PaaS)? Do we need the operating system (IaaS)?
- A legal rule about location can be met by a public cloud region in the right country; read what the rule really requires.
- Owning means paying for your busiest hour all the time. Renting follows the load, so it wins when the load changes a lot, and owning can win when the load is steady and high.