Behind the Scenes: EC2 Instance Launch
Overview of what happens behind the scenes when an AWS EC2 instance is launched, covering compute, virtualization, AMIs, EBS, networking, and security.
Series: Behind the Scenes (3 articles)
- 1Behind the Scenes: EC2 Instance Launch This article
Launching EC2 Instances
Launching an EC2 instance may look simple from the outside. A few configuration choices are made, the instance is launched, and after a short time it becomes available.
But what actually happens behind the scenes?
An EC2 instance is not simply a virtual machine that appears immediately after clicking Launch. AWS needs to allocate compute resources, prepare the operating system, connect the instance to the network, and make the required storage available.
Understanding these steps makes the EC2 architecture much easier to understand.
1. Selecting the Compute Resources
The first important concept is the instance type.
An EC2 instance type defines the compute resources available to the virtual machine, such as vCPUs, memory, network capabilities, and sometimes local storage.
When an instance is launched, AWS needs to find suitable physical capacity in its infrastructure to provide these resources.
This is one reason why an instance type is more than just a label such as t3.medium or m7i.large. It represents a specific resource configuration that needs to be supported by the underlying infrastructure.
2. Creating the Virtual Machine
EC2 uses virtualization to provide virtual servers on physical AWS infrastructure.
Modern EC2 instances are built on the AWS Nitro System, which uses dedicated hardware and software components to handle functions such as virtualization, networking, and storage.
The result is a virtual machine that has its own allocated CPU and memory resources while sharing the underlying physical infrastructure with other workloads.
From the operating system's perspective, it behaves like an independent server.
3. Loading the Operating System
The EC2 instance also needs an operating system.
This is where an Amazon Machine Image (AMI) comes into the picture.
An AMI provides the information required to create the instance's root environment, including the operating system and its configuration.
For example, an AMI may contain an Amazon Linux or Windows Server environment.
During launch, AWS uses the selected image as the basis for the instance's root storage.
A simplified view is:
AMI → Root Volume → Operating System → Running Instance
4. Attaching Storage
The operating system needs somewhere to store its files.
For many EC2 instances, this is provided through Amazon EBS (Elastic Block Store).
An EBS volume acts like a virtual disk attached to the EC2 instance. The operating system can use it for the root filesystem and, depending on the architecture, additional application data.
This creates an important separation:
EC2 = Compute
EBS = Persistent Block Storage
EBS = Persistent Block Storage
The compute resource can be replaced while the storage resource can have a different lifecycle, depending on its configuration.
5. Connecting the Instance to the Network
An EC2 instance also needs network connectivity.
When launched inside a VPC, the instance is connected through an Elastic Network Interface (ENI).
The ENI provides network characteristics such as:
- Private IP address
- Security groups
- Network connectivity
- Subnet association
The subnet determines the network location of the instance inside the VPC.
This means that an EC2 instance is not simply given an IP address independently. Its network connectivity is provided through the VPC networking layer.
6. Applying Security Controls
Security groups are associated with the instance's network interface.
They act as a virtual firewall that controls allowed inbound and outbound traffic.
For example, an application server may allow HTTP or HTTPS traffic while restricting direct access to other ports.
This security layer is applied as part of the instance's network configuration rather than being something completely separate from the instance.
7. Starting the Operating System
Once the compute, storage, and networking components are prepared, the virtual machine can boot from its root volume.
The operating system starts its normal boot process, initializes hardware and networking, and starts its configured services.
At this point, the instance becomes available for applications and other workloads.
Additional startup configuration can also be provided through user data, allowing scripts to run during the initial boot process.
Putting Everything Together
The launch process can be simplified as:
Instance Configuration
↓
Compute Capacity Allocated
↓
Virtual Machine Created
↓
AMI Used for OS Environment
↓
EBS Storage Attached
↓
Network Interface Connected
↓
Security Rules Applied
↓
Operating System Boots
↓
EC2 Instance Becomes Available
↓
Compute Capacity Allocated
↓
Virtual Machine Created
↓
AMI Used for OS Environment
↓
EBS Storage Attached
↓
Network Interface Connected
↓
Security Rules Applied
↓
Operating System Boots
↓
EC2 Instance Becomes Available
Of course, the actual AWS infrastructure is much more complex than this simplified flow. However, this model provides a useful way to understand what happens behind the scenes.
Therefore, an EC2 instance is not a single resource in isolation.
It is the result of several AWS infrastructure components working together:
Compute + Virtualization + Storage + Networking + Security + Operating System
Understanding this relationship is useful when troubleshooting EC2 issues.
For example, if an instance is running but an application cannot be reached, the problem may not be the compute resource itself. It could be related to the network interface, security group, route configuration, storage, or the application running inside the operating system.
Series: Behind the Scenes (3 articles)
- 1Behind the Scenes: EC2 Instance Launch This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article