๐Ÿš€ Understanding Amazon EC2: The Backbone of Cloud Computing

Poonam VetalPoonam Vetal
6 min read

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?

  1. You choose an Amazon Machine Image (AMI) โ€” a preconfigured template containing an OS and software.

  2. Select an instance type โ€” defines CPU, RAM, network, and storage.

  3. Attach storage โ€” like EBS (Elastic Block Store) volumes.

  4. Configure networking and security โ€” using VPC, subnets, and Security Groups.

  5. 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 TypeDescriptionUse Case
Shared (default)Your instance runs on shared hardwareCost-effective, suitable for most apps
Dedicated HostPhysical server fully allocated to youCompliance, software licensing
Dedicated InstanceRun on hardware dedicated to you (but shared across your account)Sensitive workloads
Capacity ReservationReserve capacity in an AZGuaranteed availability

๐Ÿ–ฅ๏ธ EC2 Instance Types

Each instance type is optimized for specific workloads. They are grouped by families:

FamilyDescriptionBest for
t (General Purpose)Balanced CPU & RAM (e.g., t3.micro)Small web servers, dev/test
m (General Purpose)More balanced than t, burstableMedium-sized apps, DBs
c (Compute Optimized)High-performance CPUsGaming, data processing, ML inference
r (Memory Optimized)High RAMCaching, in-memory DBs
x (Memory Optimized)Ultra high-memorySAP HANA, large in-memory analytics
i (Storage Optimized)High IOPS SSDsNoSQL DBs, data warehousing
g / p / inf (GPU)With GPU or inference chipsML training, video rendering
h1, d2, etc.Dense storageHadoop, 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 TypeDescriptionUse Case
gp3 (default)SSD, general purposeWeb servers, boot volumes
io2SSD, high IOPSDatabases
st1HDD, throughput-optimizedBig data, log processing
sc1HDD, cold storageArchival data
Instance StoreEphemeral storage on hostTemporary, 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:

TypeProtocolPortSource
SSHTCP22My IP
HTTPTCP800.0.0.0/0
HTTPSTCP4430.0.0.0/0

โš ๏ธ Never allow SSH from 0.0.0.0/0 in production.


๐Ÿงพ Cost Estimation

EC2 pricing depends on:

FactorExample
Instance typet3.micro vs m5.large
RegionMumbai vs Ohio
OSLinux (free) vs Windows (license)
TenancyShared (cheap) vs Dedicated (costly)
Storagegp3 (per GB/month) + IOPS
Data TransferOutbound traffic billed

๐Ÿ’ก Use the AWS Pricing Calculator to estimate costs before launching.

Free Tier:

  • t2.micro or t3.micro โ€” 750 hours/month

  • 30 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

StateDescription
PendingBeing created
RunningReady and accessible
Stopping/StoppedNot billed for compute, but EBS still charged
TerminatedInstance is deleted
RebootingSoft 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.


0
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 !๐ŸŽ“