Cloud Instances and Images
Level 4 · Running and paying
How a cloud server starts from a saved disk in about a minute. How more copies are added when it gets busy, and removed after.
Course contentsLesson 9 of 11
Level 1 · Virtual machines
Level 2 · The cloud
Level 3 · Where it runs
Level 4 · Running and paying
After this lesson you can
- Start a cloud instance from a machine image
- Explain why images make servers identical
- Say how the cloud decides to add a server
12 mincovers 3 glossary entries
Worth reading first: Regions and Availability Zones
From a saved disk to many identical servers
A cloud instance is a virtual machine you rent from a cloud provider, paid for while it runs. It starts from a machine image: a saved disk with the system and software already set up. Starting one takes about a minute. Autoscaling then adds or removes copies as the load rises and falls.
The image is what makes this work. Without one, each new server needs its software installed by hand or by script, which is slow and easy to get slightly wrong. With one, every copy starts out exactly the same.
Each instance has a type that sets its size, such as 2 vCPUs and 4 GB of memory. You pick the type, the image and the zone, and the cloud starts it. Bigger types cost more per hour.
Clouds offer ready-made images for Ubuntu, Debian, Windows and more. Most teams then build their own on top, with their app already inside. A new version of the app means a new image.
Autoscaling watches a number, such as how busy the CPUs are. When it stays over a line, say 70%, for a few minutes, it starts another instance from the image. When load drops, it removes the extras. You set a smallest and a largest count.
That only works if instances keep nothing that matters on their own disk. Uploads, sessions and the database live somewhere shared. Then any copy can be removed at any time, and nothing is lost.
The mistake is to log into one running instance and fix something by hand. The fix lives only on that copy. The next one autoscaling starts comes from the old image, and the bug is back.
aws ec2 run-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t3.small \
--count 1 \
--subnet-id subnet-0123456789abcdef0Worked example
A sports site on match night
A sports news site runs 3 instances on a quiet day. On a cup final night, visits jump eightfold in ten minutes.
Autoscaling sees the CPUs pass 70% and starts copies from the site's image, up to 20. After the match, it scales back down to 3 by midnight.
The words for this lesson3
Check yourself
You fix a bug by logging into one running instance. Why does it come back?
Finished this lesson?
Marking it complete also marks its 3 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.