Sub topic 8
IaaS: Renting Infrastructure
Infrastructure as a Service (IaaS) gives you virtual computing building blocks on demand: virtual machines, storage, and networks. This chapter explains what the provider runs, what you run, and the mistakes people make when they first use it.
This chapter assumes you know what a server, an operating system, and an application are. It also assumes you know basic networking terms such as IP address and HTTP. It builds on the earlier chapters on virtualization, the technology stack, and the service model idea.
What IaaS Provides
With IaaS you rent the lowest layers of the stack as a service. The provider owns the buildings, power, cooling, physical servers, disks, and network cables. Virtualization (software that splits one physical machine into many isolated virtual ones) turns that hardware into resources you request through a web console, a command line, or an API.
The core IaaS resources fall into four groups:
- Compute: virtual machines (VMs), called EC2 instances on AWS, Compute Engine instances on Google Cloud, and virtual machines on Azure.
- Storage: block storage (virtual disks attached to one VM), object storage (files addressed by key over HTTP), and file storage (shared network file systems).
- Networking: virtual private networks, subnets, IP addresses, routing, firewalls, and load balancers.
- Supporting pieces: machine images, snapshots, and key pairs for login.
You get a machine that behaves like a physical server. You pick the operating system, install software, open ports, and decide how it is configured. That freedom is the main reason to choose IaaS.
Who Manages What
The provider manages everything up to and including the hypervisor, the software layer that creates and isolates virtual machines. You manage everything from the guest operating system upward.
This split has practical consequences. If a virtual machine's operating system has an unpatched vulnerability, that is your problem. If a physical host loses power, the provider handles the hardware, but your VM may still go down, and it is up to you to design the application to survive that.
Launching a Virtual Machine
The following command launches one virtual machine with the AWS CLI. It shows the choices you make as an IaaS customer.
# IaaS: you choose the machine image and size, then manage the OS and everything above it.
# The AMI ID below is a placeholder; use an image ID that exists in your region.
aws ec2 run-instances \
--image-id ami-0123456789abcdef0 \
--instance-type t3.micro \
--count 1Each option matters:
--image-idselects the machine image (an AMI on AWS). The image contains the operating system and any preinstalled software. Your choice here decides which OS you must patch.--instance-typeselects the size: the number of virtual CPUs, the amount of memory, and network capacity.t3.microis a small, general-purpose size.--countsets how many identical instances to start.
A real launch usually also needs a key pair for SSH login, a security group (a virtual firewall), and a subnet. If you omit them, AWS uses defaults where the account has a default network. Those defaults are often too open for production.
After the call returns, the instance moves through states: pending, then running. Billing for compute starts when it is running. You then log in, install your software, and operate it like any server.
Instance Lifecycle
An instance has a lifecycle that you control, and the state you choose affects cost and data.
The difference between stopped and terminated catches many beginners:
| State | Compute charges | Disk (block storage) | Can be restarted |
|---|---|---|---|
| running | Yes | Charged | Not applicable |
| stopped | No | Still charged | Yes |
| terminated | No | Root disk deleted by default | No |
A stopped instance costs nothing for compute but still costs for its attached disks. A terminated instance is gone. By default its root disk is deleted with it, so any data stored only there is lost.
Storage Choices and Data Durability
IaaS offers several kinds of storage, and each has a different lifetime and access pattern.
- Instance store: disks physically attached to the host. They are fast, but their contents vanish when the instance stops or the host fails.
- Block storage: network-attached virtual disks (EBS on AWS). They persist independently of the instance and can be snapshotted.
- Object storage: a flat store of files addressed by key (S3 on AWS). It is accessed over HTTP, scales to very large sizes, and is not mounted like a disk by default.
A common design rule is to treat the VM itself as replaceable. Keep durable data on block or object storage, and keep configuration in scripts or images. Then you can terminate and recreate a broken instance without losing anything important.
Networking You Configure
On IaaS you build your own virtual network. You define an address range, split it into subnets, attach route tables, and control traffic with firewall rules.
A typical layout puts web servers in a public subnet, reachable from the internet through a load balancer, and databases in a private subnet with no direct internet route. Security groups act as stateful firewalls: if you allow an inbound request, the reply is allowed automatically.
What You Gain and What You Pay For
IaaS suits several situations:
- You need a specific operating system, kernel setting, or installed software that a managed platform does not allow.
- You are moving an existing application to the cloud with few changes, often called "lift and shift."
- You need full control over networking and security configuration.
- Your workload is unusual, such as one that needs special hardware like GPUs.
The cost of that control is operational work. You are responsible for:
- Patching and hardening the operating system.
- Installing and updating the runtime and middleware.
- Configuring monitoring, logging, and backups.
- Scaling: adding or removing instances, and balancing traffic between them.
- Designing for failure, for example by running instances in more than one availability zone.
The provider offers tools for these jobs, such as auto scaling groups and snapshot schedules. But you must set them up and keep them correct. IaaS removes hardware work, not system administration work.
Billing in IaaS
IaaS follows the pay-as-you-go model described earlier, with several separate meters:
- Compute: billed per second or per hour while the instance runs, according to its size.
- Storage: billed per gigabyte per month for provisioned disks, whether or not the instance is running.
- Data transfer: data leaving the provider's network to the internet is charged. Inbound traffic is usually free.
- Extras: public IP addresses, load balancers, and snapshots can each add charges.
Discount options exist for steady workloads. Reserved or committed-use pricing lowers the rate in exchange for a one- or three-year commitment. Spot or preemptible capacity is cheaper, but the provider can reclaim it with short notice, so it fits interruptible batch jobs.
Common Errors and Gotchas
- Paying for idle machines. A forgotten running instance bills continuously. Tag resources and review them regularly.
- Leaving unattached disks behind. Terminating an instance does not always delete extra volumes you attached. They keep billing.
- Storing the only copy of data on an instance. If the instance is terminated or its host fails, the data is gone. Use snapshots and durable storage.
- Treating one instance as highly available. A single VM in one availability zone is a single point of failure.
- Assuming the provider patches your OS. It patches the hypervisor and hardware. The guest operating system is yours.
- Ignoring data transfer fees. Moving large amounts of data out of the cloud can cost more than storing it.
- Hard-coding credentials on the instance. Use roles or identity services so that secrets are not written into images or scripts.
IaaS Compared with the Next Layer
IaaS sits at the bottom of the three classic service models. It gives the most control and demands the most effort. A PaaS, covered next, takes over the operating system, runtime, and scaling mechanics so that you supply only code. The more the provider manages, the less you can customize and the less you have to operate.
Exercise
A team runs a web application on one EC2 instance. They stop the instance for the weekend to save money. What do they still pay for, and what happens to the data on the root disk? Then, what would change if they terminated the instance instead?
Show answer
While the instance is stopped, they pay nothing for compute but still pay for the attached block storage, and the data on the root disk is preserved so the instance can be started again. If they terminate the instance, compute charges also stay at zero, but the instance cannot be restarted, and the root disk is deleted by default, so data stored only there is lost. Extra attached volumes may remain and keep billing unless they are set to delete on termination.
Exercise
Your company must run a legacy application that needs a specific old Linux kernel version and a custom network configuration. Which service model fits, and which layers will your team be responsible for?
Show answer
IaaS fits, because it lets you choose the operating system and kernel and configure the network yourself. Your team is responsible for everything from the guest operating system upward: OS patching, the runtime and middleware, the application and its data, firewall rules, monitoring, backups, and scaling. The provider handles the hypervisor, physical hardware, and data center.