# AWS EC2 notes

Hello Readers,

This is part 2 of the 5-part Series on cracking the AWS Solutions Architect - Associate Exam.  [Click here](https://blog.hellokarthic.com/aws-s3-notes)  for part 1 - AWS S3.

I've divided the notes into a 5 part series.

- **Part 1:**  [Introduction and AWS S3](https://blog.hellokarthic.com/aws-saa-notes) 
- **Part 2:**  [AWS EC2](https://blog.hellokarthic.com/aws-ec2-notes) 
- **Part 3:**  [Databases](https://blog.hellokarthic.com/aws-db-notes) 
- **Part 4:**  [DNS, VPC, and HA(High-Availability)](https://blog.hellokarthic.com/aws-dns-vpc-ha-notes) 
- **Part 5:**  [Application Services and Serverless + Bonus](https://blog.hellokarthic.com/aws-applications-serverless-notes) 


### EC2 Notes
---
#### EC2 Types
- On-Demand
- Reserved
- Spot
- Dedicated Hosts

#### Reserved Instance(RI) Types
- Standard RI - Upfront, greater discount - No changing instance types
- Convertible RI - lesser discount (54% off on-demand) - Changeable instance types - But should be equal or greater value
- Scheduled RI - only needed for a fraction of day/month/year

#### EC2 Mnemonic ( To remember various instance types supported )
FIGHT DR MC.PIXZ from AU

F - FPGA;
I - For IOPS;
G - Graphics;
H - High Disk throughput;
T- t2 cheap;

D - Density;
R -  RAM;

M - main/general purpose;
C - Compute;
P - Graphics;
X - Xtreme memory;
Z - Xtreme memory and CPU;

A - ARM-based workloads;
U - Bare metal;

#### EC2 general notes:
- General-purpose SSD can have 100 burstable up to 3000 IOPS. 
- 3 IOPS / GB
- **NOW, Root Volume can be encrypted during EC2 creation**
- Root Volume has 3 options
	- (gp2) General-purpose SSD
	- (io1) Provisioned IOPS SSD
	- (Standard) Magnetic

- But, Additional EBS volume has 5 options
	- (gp2) General-purpose SSD [ Most workloads ]
	- (io1) Provisioned IOPS SSD [ Databases ]
	- (standard) Magnetic [Infrequently accessed Workloads] - PREVIOUS GEN
	- **(sc1) Cold HDD [ Cheapest storage; File Servers]**
	- **(st1) Throughput optimized HDD [ Used in Data-warehousing ]**

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1609074773892/CGRDO-q3L.png)
 [Image Credit](https://www.udemy.com/course/aws-certified-solutions-architect-associate/) 

- Security groups are **Stateful** - That means if you create inbound rules, then it automatically presumes outbound as well. Unlike NACL, which is **Stateless**- You MUST mention outbound specifically.
- EBS Snapshots exists on S3
- Snapshots are incremental - only the last blocks that have changed since your last snapshot are only moved to S3.
- EBS vs Instance Store
	- **For EBS backed Instance:** Root device of an instance (from the AMI) is basically an Amazon EBS volumes that are created from EBS snapshots
	- **For Instance Store backed Instance:** Root device of an instance (from the AMI) is basically created from a template store in S3.
	- **Instance Store:** You cannot stop; you can only reboot/terminate. Also, Instance Store doesn't have Volume attached to it.
	- In both storage format - if you **reboot**, you won’t lose data
- ENI (Elastic Network Interface)
	- For basic networking up to 10Gbps
- ENA (Elastic Network Adapter) - Uses **SR- IOV (Single Root I/O Virtualization)**
	- Supports up to 100 Gbps N/w speeds [In Older-gen, Virtual Function(VF) is used, which supports only up to 10 Gbps]
- EFA (Elastic Fabric Adapter)
	- Can be attached to EC2 for High perf computing(HPC) or ML application

**Note:** You can only share unencrypted EBS snapshots as public. But encrypted cannot be shared as a snapshot or AMI.

- Cloudwatch with EC2 can monitor
	- CPU
	- Network
	- Disk
	- Status Checks
- Curl http://169.254.169.254/latest/meta-data to get instance specific information (Also, try replacing **meta-data** with **user-data** ).
- EFS
	- It supports network file system version 4 (NFSv4) protocol
	- Designed for **Linux & Unix**.
	- you only pay for the storage you use. (No pre-provisioning cost)
	- Read after write consistency
- FSX for Windows
	- A managed windows server that runs Windows Server message block (SMB) based file servers
	- Designed for **windows & windows applications**
	- Supports AD users ACL, group & security policies, DFS, and replication
- FSX for Lustre.
	- For compute-intensive, ML, HPC millions of IOPS.
	- Stores directly on S3.
- 3 types of Placement groups
	- Clustered ( single AZ ) - For low latency, High N/w
	- Spread ( Single instance in each AZ, So separate AZ ) - To avoid hardware failure
	- Partitioned (multiple instances in each AZ, So separate partitioned AZ )
- The hypervisor used in EC2
	- Xen (previously used)
	- Nitro (Currently used, It’s AWS’ own hypervisor)
- Standard RI cannot be moved between regions
- In the Spread Placement group,  Each AZ can have a max of 7 EC2 instances only.

Continue reading  [Part 3 - AWS Databases](https://blog.hellokarthic.com/aws-db-notes) ...
