AWS EC2 Instance (Day 7)

AWS EC2 Instance (Day 7)

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

  1. On Demand Instances

  2. Reserved Instances

  3. Spot Instances

  4. Dedicated Host

  5. Dedicated Instance

  6. Capacity Reservation

  7. 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

  1. EBS Volume

  2. 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

  1. General Purpose (gp2,gp3) - SSD

  2. Provisioned IOPS (io1,io2) - SSD high performance

  3. Throughput (st1) - HDD frequently access data with cheaper price.

  4. Cold (sc1) - HDD not frequently access data with cheaper price.

  5. 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

  1. Standard Tier

  2. 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.