By the end of this lesson you will be able to
- describe how Pennyworth Crafts runs its online shop today, and why that is becoming a problem
- find your way around a practice cloud: the diagram, the cost meter and the command box
- look around with
help,list,showandvisit - make a simple resource, check that it exists, and remove it again
- explain how time and credits work in the practice cloud, using
waitandbill
“It lives in the back room”
On Sophie Clarke's first morning as Pennyworth Crafts' junior cloud administrator, the owner, Beth Carrington, gives her a tour. Pennyworth Crafts sells yarn, paper, paints and craft kits through its website, www.pennyworth.example. Orders are packed in the warehouse at the back of the building, and next to the warehouse is a small, warm room with one humming computer on a shelf.
“That's the shop,” Beth says. “The website, the product list, every customer and every order: all on that one machine. When we run a sale it slows to a crawl, and last month the power went off for an afternoon and we took no orders at all. I want it moved to the cloud before the autumn sale. Ian will show you how.”
Ian Woodward, a cloud engineer who works with Pennyworth Crafts two days a week, is waiting at Sophie's desk. “Before we move anything,” he says, “let's get you comfortable in a cloud where mistakes cost nothing.”
The shop today
Today, everything runs on the office server. A server is simply a computer whose job is to provide something for others: here, web pages and the shop's data. When a customer types www.pennyworth.example, the internet's naming system (called DNS, the Domain Name System) turns that name into the office server's address, 203.0.113.80, and the customer's browser fetches the page from there. That works, but it has the weaknesses Beth described:
- One machine has a fixed amount of power. When too many visitors arrive at once, pages get slow and some fail.
- One machine in one room is a single point of failure. A power cut, a broken disk or a failed internet line stops the shop completely.
- The office internet line is shared with everything else the staff do, and it is slower than the connections inside a data centre.
Moving to the cloud does not make these problems disappear by magic, but it gives Pennyworth Crafts the tools to deal with each of them: more machines when they are needed, copies in more than one building, and fast connections. Most of this course is about using those tools well.
Your practice cloud
Throughout this course you will work in practice clouds like the one below. Each is a pretend cloud provider that runs entirely inside your web browser. Nothing you type reaches a real provider, costs real money or affects a real website, so experiment freely. If you get into a muddle, press Reset this practice cloud.
- The line at the top, the cost meter, shows the practice cloud's clock, how much everything you have made costs per hour right now, and how much has been spent since you started.
- The diagram shows what exists. The internet, your laptop and the office server are along the top. As you build things, networks appear as large dashed boxes with smaller boxes (subnets) inside them, holding servers, databases and so on. On a phone, slide the diagram sideways to see all of it.
- The dark box is the command box. Type a command and press Enter (or Run). The prompt,
sophie@cloud>, shows who you are working as. Press the up arrow key to bring back your last command. - The buttons after Try: run a suggested command for you.
Real cloud providers are controlled in three main ways: through a website (usually called the console), through commands typed at a command line, and through files that describe what should exist (you will meet those in lesson 9.3). The practice cloud uses short typed commands, because they are quick to learn, easy to repeat exactly, and close to how professionals work. The command names are invented for this course, but every idea behind them is one you will find with real providers.
Try the three buttons. show office describes the office server. visit fetches a web page from your laptop, the way a customer's browser would, and tells you which machine answered:
sophie@cloud> visit http://www.pennyworth.example/
www.pennyworth.example is 203.0.113.80 (the office server)
200 OK (page: Pennyworth Crafts home page) served by the office server
The first line is the name lookup. The second is the answer: 200 OK is the web's standard code for “here is the page you asked for”. You will also meet 404 Not Found (no such page), 403 Forbidden (you are not allowed to see it), 500 (the website itself went wrong) and 503 Service Unavailable (the website is too busy or has nothing working behind it). The shop has a few pages you can visit: / (the home page), /products, /basket and /about.
lookup shows just the name lookup. Its time-to-live of 86400 seconds (24 hours) means computers that have looked the name up may remember the answer for a day before asking again. Lesson 3.4 explains this properly, and it will matter a great deal on moving day, in lesson 10.2.
Finding your way with help, list and show
You do not need to memorise commands. Four are enough to find everything else:
| Command | What it does |
|---|---|
help | Lists the main commands. help followed by a topic, such as help storage, lists the commands for that topic. |
list | Lists everything that exists. list servers, list buckets and so on list one kind of thing. |
show name | Shows the details of one thing, such as show web-1. |
visit web address | Fetches a web page from your laptop. |
In a brand-new practice cloud, list shows very little: two built-in images (ready-made starting points for servers, explained in lesson 2.2) and one user, you:
sophie@cloud> list
Images:
standard (built in) plain server operating system
web (built in) operating system with the shop's web software installed
Users:
sophie everything (*); two-step sign-in on
“Everything (*)” means your user may do anything in this cloud account. That is normal for the person setting up a new account, but in module 7 you will learn why most people should have far less.
Busy days
Ian wants Sophie to see Beth's problem for herself. The practice cloud can pretend to be the shop's visitors: traffic sets how many requests (page and picture fetches) visitors make each second. Time in the practice cloud only moves when you say so, with wait, and status then reports how the shop is coping.
On a normal day, about 40 requests a second, the office server copes:
sophie@cloud> status
Shop status at Monday (day 1), 09:30:
Visitors: 40 requests a second (30% from far away)
www.pennyworth.example points to the office server
Requests that failed: 0%
Average time for a page: 117 ms
office server processor use 67%
Cost right now: 0 credits an hour
During a sale, at 90 requests a second, it cannot keep up. Its processor would need to work at 150% of its capacity, which is impossible, so a third of the requests fail and the others take the best part of a second:
sophie@cloud> status
Shop status at Monday (day 1), 10:00:
Visitors: 90 requests a second (30% from far away)
www.pennyworth.example points to the office server
Requests that failed: 33.3%
Average time for a page: 757 ms
office server processor use 100% (OVERLOADED: it would need 150%)
Cost right now: 0 credits an hour
A processor (or CPU) is the part of a computer that does the work; “processor use” is how much of its capacity is busy. Around 70% is comfortable. Near 100%, everything queues and slows down; beyond it, work is turned away. Notice also “30% from far away”: some customers live a long way from the office, and every page takes them longer to reach. Lesson 5.4 deals with that.
The cost is zero because nothing is running in the cloud yet. The office server has its own costs, of course (the machine, its electricity, the internet line and the time spent looking after it), but they do not appear on a cloud bill.
Making and removing things
Everything you make in a cloud is called a resource: a server, a network, a disk, a storage bucket and so on. Almost every resource is made with create followed by the kind of resource, a name you choose, and some settings. Here is the simplest one, a storage bucket, a place to keep files that you will study properly in lesson 4.2:
sophie@cloud> create bucket pennyworth-notes region north
Created bucket pennyworth-notes in region north. It is private. Objects will be at https://pennyworth-notes.storage.cloud.example/<object>.
region north says which of the provider's locations should hold it. This provider has two regions, North and South, and lesson 2.4 explains how to choose. Names follow a simple rule: lower-case letters, digits and hyphens, starting with a letter. pennyworth-notes is fine; Pennyworth_Notes is refused with a message saying so. Real providers have similar rules, and sticking to lower case and hyphens everywhere saves trouble.
To remove a resource, use delete followed by its kind and name, such as delete bucket pennyworth-notes. There is no “are you sure?” question and, in most cases, no way back. Real providers are the same: a deleted resource is gone, which is why later lessons spend time on backups and on who is allowed to delete things.
Time and credits
Cloud providers charge for what you use, usually by the hour or by the second for machines, and by the amount stored or sent for data. The practice cloud charges in credits, a pretend unit that stands in for money. The prices are simple round numbers chosen for teaching; prices lists them all. Real prices vary by provider and by region, and change over time, but they follow the same patterns.
Because nothing happens until you wait, you can move time on by minutes, hours or days and watch the bill grow. In the practice cloud below, a small server called web-1 is already running. Wait a few hours and look at the bill, then stop the server and look again:
sophie@cloud> bill
Bill at Monday (day 1), 13:00:
Item Spent Per hour
web-1 8.01 2
Total spent: 8.01 credits. Cost right now: 2 credits an hour, about 1,441 a month.
A small server costs 2 credits an hour while it runs, so four hours cost 8 credits. The extra 0.01 is its disk, the storage its software lives on, which is priced per gigabyte per month and charged for as long as it exists, running or not. After stop server web-1 the hourly cost falls to 0.001: the server no longer runs, but its disk is still kept, and still charged. That pattern (pay for machines while they run, pay for storage while it exists) is the heart of cloud pricing, and module 8 is all about it.
Get into the habit of glancing at the cost meter after every change. In a real cloud account, a forgotten server or database carries on charging day and night until somebody deletes it. Many teams' first cloud surprise is a bill for something they made “just to try” and forgot.
Exercises
Exercise 1 · How much can the office server take?
Use the practice cloud below to find out how many requests a second the office server can handle before it is overloaded.
Exercise 2 · Make your first resource
Luke Palmer, Pennyworth Crafts' web developer, wants somewhere to keep notes about the move. In the practice cloud below, create a bucket called pennyworth-notes in the North region.
Exercise 3 · A busier day
A newsletter goes out and visitors reach 75 requests a second. Use traffic, wait and status in the practice cloud below to find out what percentage of requests fail. Wait at least 10 minutes before you ask for the status.
Exercise 4 · Stop the meter
In the practice cloud below, a small server called web-1 is running. Let 4 hours pass, then stop the server so that it no longer costs 2 credits an hour. Do not delete it: Luke still needs it tomorrow.
Exercise 5 · Which command?
Match each question to the command that answers it.
Quick check
Choose an answer to see whether you are right and why.
Why did Pennyworth Crafts take no orders during last month's power cut?
The office server was a single point of failure: when it lost power, there was no other copy of the shop anywhere. Customers' own electricity was fine, the name still existed, and the shop was not in the cloud at all.
In the practice cloud, what makes time pass?
The clock only moves when you type wait, followed by a number of minutes, hours or days. That lets you see a day's costs, or an hour of busy traffic, in a moment. Reset puts the clock back to Monday 09:00.
You visit a page and get 404 Not Found. What does that mean?
404 means the server was reached but has nothing at that address, often because of a typing mistake. An overloaded website gives 503, a page you may not see gives 403, and a normal page gives 200 OK.
You stop a server instead of deleting it. What do you keep paying for?
A stopped server does no work, so its hourly price stops. Its disk still exists, holding its software and data ready for the next start, and storage is charged for as long as it exists.
Summary
- Pennyworth Crafts runs its whole shop on one office server, which is too small for busy days and is a single point of failure.
- A practice cloud has a cost meter (clock, cost per hour, amount spent), a diagram of what exists, and a command box. Nothing you do there affects anything real.
help,list,showandvisitlet you find your way around;statusreports how the shop is coping with thetrafficyou set.- Everything you make is a resource: made with
create, removed withdelete, which cannot be undone. - Time moves only when you
wait. Costs are in pretend credits: machines are charged while they run, storage while it exists, andbillshows the total.
Found a mistake on this page, or something unclear? Report a problem and mention “Cloud Computing Basics Lesson 1.2”.
