EC2 is a webservice from AWS that provides resizable compute services in the cloud.
Resizable: Scale up/ scale down, scale out /scale in
EC2 is regional, servers = to EC2 instance
750 hours are free per month
Pricing Modes in EC2
On Demand Instances
Reserved Instances
Spot Instances
Dedicated Host
Dedicated Instance
Capacity Reservation
Saving Plan
EC2 families / instance type
Instance Type = CPU + Memory
scalability is scale up and scale down, scalability can be achieved by changing the instance type.
Data is not lost why doing the scalability
we need to stop the ec2 instance to change the instance type
if we want to change the instance type data in the instance will not be lost because data is a stored in volumes.
Volumes
EBS Volume
Instance Store Volume (ISV)
EBS Volume
Persistent storage / permanent
if we stop and start the ec2 instance data is not lost
EBS volume has maximum size 16 TB and EBS is billable.
Types of EBS Volumes
General Purpose (gp2,gp3) - SSD
Provisioned IOPS (io1,io2) - SSD high performance
Throughput (st1) - HDD frequently access data with cheaper price.
Cold (sc1) - HDD not frequently access data with cheaper price.
Magnetic (Standard) - HDD Previous generation
GP2 is a default EBS volume type IOPS = input output per second
root volume supports these volumes type (gp2,gp3,io1,io2 and standard)
root volume does not support st1 and sc1.
Up to 16 EC2 instances at a time can be attached.
Instance Store Volume (ISV)
not persistent storage / temporary storage
If we stop and start the ec2 instance data is lost / gone / deleted
If we terminate the EC2 instance by default root volume will also be deleted because delete on termination is enabled.
Snapshots
Backup of volume is called snapshot or point in time copy of the volume
EBS snapshots are created from EBS volumes
We can create snapshots from volumes
We can not attached snapshots to the EC2 instance we have to create a volume from a snapshots and attached to the EC2 instance
snapshots are stored in S3
snapshots does not have any availability zone, snapshots are regional
by default snapshots are private if required we can make it public
To create a snapshot we no need to stop the EC2 instance
EBS Snapshot Tiers
Standard Tier
Archive Tier
Recycle Bin
Setup retention rules to retain deleted snapshots so we can recover them after accidental deletion. ( retention period 1 day to 365 days)
All snapshots can be moved to recycle bin or selected snapshots can also be moved using tags.
- Fast Snapshot Restore (FSR)
Forcefully initialization of snapshot to have no latency on the first use.
-Key Management Service (KMS)
By default volumes, snapshots are not encrypted
encryption and decryption is managed by AWS
all encryption keys are stored in kms
encryption keys are for encryption purpose
Data Life Cycle Manager
it is used to take snapshots automatically / schedule volumes that should get snapshots will be identified by tags.