๐ Understanding Amazon EC2: The Backbone of Cloud Computing

If you're stepping into the world of cloud infrastructure, Amazon EC2 (Elastic Compute Cloud) is likely your first serious encounter. EC2 powers the very essence of compute in AWS โ enabling developers to spin up virtual machines in minutes, without worrying about physical hardware.
But beneath the simplicity lies a highly configurable, feature-rich platform. In this blog, weโll explore how EC2 works, instance types, tenancy, volumes, AMI, security, and cost estimation โ everything you need to know before deploying a production-grade EC2 environment.
๐ง What Is EC2?
Amazon EC2 is a web service that provides resizable compute capacity in the cloud. In simpler terms, it's a way to launch virtual machines (VMs), known as instances, that you can configure to run your applications just like physical servers.
๐๏ธ How Does EC2 Work?
You choose an Amazon Machine Image (AMI) โ a preconfigured template containing an OS and software.
Select an instance type โ defines CPU, RAM, network, and storage.
Attach storage โ like EBS (Elastic Block Store) volumes.
Configure networking and security โ using VPC, subnets, and Security Groups.
Launch the instance โ which boots in seconds and can be SSH'ed into or accessed via public IP.
๐ง Tenancy in EC2
Tenancy defines where your instance runs physically.
Tenancy Type | Description | Use Case |
Shared (default) | Your instance runs on shared hardware | Cost-effective, suitable for most apps |
Dedicated Host | Physical server fully allocated to you | Compliance, software licensing |
Dedicated Instance | Run on hardware dedicated to you (but shared across your account) | Sensitive workloads |
Capacity Reservation | Reserve capacity in an AZ | Guaranteed availability |
๐ฅ๏ธ EC2 Instance Types
Each instance type is optimized for specific workloads. They are grouped by families:
Family | Description | Best for |
t (General Purpose) | Balanced CPU & RAM (e.g., t3.micro) | Small web servers, dev/test |
m (General Purpose) | More balanced than t , burstable | Medium-sized apps, DBs |
c (Compute Optimized) | High-performance CPUs | Gaming, data processing, ML inference |
r (Memory Optimized) | High RAM | Caching, in-memory DBs |
x (Memory Optimized) | Ultra high-memory | SAP HANA, large in-memory analytics |
i (Storage Optimized) | High IOPS SSDs | NoSQL DBs, data warehousing |
g / p / inf (GPU) | With GPU or inference chips | ML training, video rendering |
h1, d2, etc. | Dense storage | Hadoop, analytics |
๐ Tip: Always choose T2/T3 micro for low-cost dev/test workloads. For production, go for M, C, or R based on your compute vs memory needs.
๐พ EBS: Elastic Block Store
EC2 uses EBS to store your instance's OS, files, and application data. Think of it as a virtual hard disk.
Volume Type | Description | Use Case |
gp3 (default) | SSD, general purpose | Web servers, boot volumes |
io2 | SSD, high IOPS | Databases |
st1 | HDD, throughput-optimized | Big data, log processing |
sc1 | HDD, cold storage | Archival data |
Instance Store | Ephemeral storage on host | Temporary, fast access (not persistent) |
๐ก Important: If your instance crashes, EBS volumes persist, but instance store volumes do not.
๐ธ What is an AMI (Amazon Machine Image)?
An AMI is a blueprint to create an EC2 instance. It contains:
OS (Amazon Linux, Ubuntu, Windows, etc.)
Applications
Configurations
Optional attached volumes
You can use:
AWS-provided AMIs
Custom AMIs (you create from existing EC2s)
Marketplace AMIs (third-party software)
Use Case: After hardening a server, create a custom AMI to clone that configuration to multiple instances.
๐ Security Groups (The Virtual Firewalls)
A Security Group (SG) controls what traffic can enter or leave your EC2 instance.
It's stateful โ if you allow inbound port 22 (SSH), the response is automatically allowed.
You can define:
Inbound rules: e.g., allow HTTP (80), HTTPS (443), SSH (22)
Outbound rules: usually allow all
Example Rule:
Type | Protocol | Port | Source |
SSH | TCP | 22 | My IP |
HTTP | TCP | 80 | 0.0.0.0/0 |
HTTPS | TCP | 443 | 0.0.0.0/0 |
โ ๏ธ Never allow SSH from 0.0.0.0/0 in production.
๐งพ Cost Estimation
EC2 pricing depends on:
Factor | Example |
Instance type | t3.micro vs m5.large |
Region | Mumbai vs Ohio |
OS | Linux (free) vs Windows (license) |
Tenancy | Shared (cheap) vs Dedicated (costly) |
Storage | gp3 (per GB/month) + IOPS |
Data Transfer | Outbound traffic billed |
๐ก Use the AWS Pricing Calculator to estimate costs before launching.
Free Tier:
t2.micro
ort3.micro
โ 750 hours/month30 GB EBS storage
Valid for 12 months after account creation
๐ Key Pairs & Access
When launching an instance, youโre prompted to choose or create a Key Pair (.pem file):
Used for SSH access (Linux)
Windows instances use it to decrypt the admin password (RDP login)
Keep it safe โ you canโt download it again
Commands to SSH (from Linux/macOS terminal or Git Bash):
chmod 400 my-key.pem
ssh -i my-key.pem ec2-user@<public-ip>
๐ Lifecycle of an EC2 Instance
State | Description |
Pending | Being created |
Running | Ready and accessible |
Stopping/Stopped | Not billed for compute, but EBS still charged |
Terminated | Instance is deleted |
Rebooting | Soft restart |
๐ก๏ธ IAM Roles for EC2
You can attach an IAM Role to an instance to allow it to:
Access S3 buckets
Write logs to CloudWatch
Call other AWS services
This is better than storing AWS credentials inside the instance.
๐ Elastic IPs
By default, EC2 instances get a dynamic public IP. If you stop/start the instance, this IP changes.
Use Elastic IP (a static public IP) if:
You need a fixed IP (e.g., for DNS)
Hosting production APIs or websites
โ ๏ธ Youโre charged for unused Elastic IPs, so release them if not in use.
๐งช Monitoring: CloudWatch Integration
Every EC2 instance can be monitored using CloudWatch for:
CPU utilization
Disk I/O
Network traffic
Status checks
You can also set up alarms to send alerts when thresholds are crossed.
โจ Pro Tips
Use Spot Instances for batch jobs and save up to 90%.
Use Auto Scaling Groups for apps with traffic spikes.
Always back up EBS volumes with Snapshots.
Use Placement Groups for high-performance clustered computing.
Tag your instances for easier tracking in billing.
๐งฉ Summary
Amazon EC2 is not just a virtual machine service โ itโs a powerful compute engine that adapts to workloads ranging from personal projects to massive enterprise applications. Understanding how tenancy, instance types, storage, pricing, and networking come together helps you architect cost-effective and secure cloud environments.
Subscribe to my newsletter
Read articles from Poonam Vetal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Poonam Vetal
Poonam Vetal
I am student from Pune institute of computer technology !๐