AWS EC2 Cheat Sheet

AWS EC2 Cheat Sheet

AWS EC2 Cheat Sheet:

Please find AWS EC2 Cheat Sheet below. Please note this is my personal AWS EC2 Cheat Sheet, if it is not upto date please do let me know.

  • EC2 Types
  • EC2 purchasing Option
  • EC2 Placement Groups
  • Security Group
  • Automatic Scaling Group, Scaling types
  • EC2 Instance Connect, EC2 Instance Store, EC2 Instance User Data and EC2 Instance Metadata
  • EBS, EFS

EC2: Elastic Compute. Infrastructure as a Service (IaaS)

EC2 Instance Types:

  1. General Type – General purpose
  2. Compute Optimized – Great for compute intensive task which requires high performance.
  3. Memory Optimized – Fast performance for large data sets in-memory.
  4. Storage Optimized – great for storage intensive tasks that requires high sequence R/W.

Security Group: Firewall fir EC2. Accepts only allow requests. Security groups are locked down to region or VPC

EC2 User Data: Boot strapping, scripts that runs at the instance first start with root privileges.

EC2 Instance Store: Connect you EC2 with browser. Need port 22 open and work only for Amazon Linux.

EC2 Instance Metadata: metadata= information about EC2. It allows EC2 instances to learn about themselves without using any IAM roles. http://169.254.169.254/latest/meta-data

EC2 Purchasing Options:

analogy of staying in hotel room

  1. On-Demand Instances – short workload, predictable pricing, pay by second. It has the highest cost but no upfront payment.
  2. Reserved (1 & 3 years): Up to 72% discount compared to On-demand. You reserve a specific instance attributes (Instance Type, Region, Tenancy, OS) Reservation Period – 1 year (+discount) or 3 years (+++discount). Payment Options – No Upfront (+), Partial Upfront (++), All Upfront (+++). Reserved Instance’s Scope – Regional or Zonal. You can buy and sell in the Reserved Instance Marketplace A. Reserved Instances – long workloads     B. Convertible Reserved Instances – long workloads with flexible instances.
  3. Savings Plans (1 & 3 years) –commitment to an amount of usage, long workload. Commit to a certain type of usage ($10/hour for 1 or 3 years). Usage beyond EC2 Savings Plans is billed at the On-Demand price. Locked to a specific instance family & AWS region. Flexible across: Instance Size (e.g., m5.xlarge, m5.2xlarge), OS (e.g., Linux, Windows), Tenancy (Host, Dedicated, Default)
  4. Spot Instancesshort workloads, cheap, can lose instances (less reliable). Upto 90% discount. The MOST cost-efficient instances in AWS. Not suitable for critical jobs or databases,
  5. Dedicated Hosts – book an entire physical server, control instance placement
  6. Dedicated Instancesno other customers will share your hardware. The most expensive option, allows you address compliance requirements and use your existing server bound software licenses. Useful for software that have complicated licensing model or for companies that have strong regulatory or compliance needs. Purchasing Options: On-demand – pay per second for active Dedicated Host and Reserved – 1 or 3 years (No Upfront, Partial Upfront, All Upfront)
  7. Capacity Reservationsreserve capacity in a specific AZ for any duration. Combine with Regional Reserved Instances and Savings Plans to benefit from billing discounts. You’re charged at On-Demand rate whether you run instances or not. Suitable for short-term, uninterrupted workloads that needs to be in a specific AZ
  8. Spot fleet: set of spot instances + (optional) on demand instances. Allows us to automatically request spot instances with lowest price.

EC2 Placement Groups:

  1. Cluster Placement group: cluster instances into low latency group in single AZ. Pros- great network. Cons – If rack fails, all instances fails at the same time.
  2. SPREAD placement group: spread across underlying hardware. Max 7 instances per AZ. Good for – highly available applications and critical applications.
  3. PARTITION placement group: spread across many different partitions withing AZ. Scales upto 100s of EC2 per group. Use cases – Hbase, Hadoop, cassendra and HDFS.

Elastic Network Interface (ENI): A logical component in VPC that represent virtual network card. ENI are bound to specific AZ. ENI consists of primary private IP, one or more secondary IP, one public IPV4, one elastic IP per IPV4, one or more security groups and a mac address.

EC2 Hibernate: With EC2 hibernate -The in-memory RAM is preserved. – The instance boot is faster. – Under the hood the RAM state is written in EBS. – The root volume must be enough. An instance can not be hibernated for more than 60 days.

Amazon Machine Image (AMI): An AMIT are a customization of EC2 instances. Bound to specific AZ. 1) Public AMI 2) Your own AMI 3) AWS marketplace AMI.

EC2 Instance Store: If you need high performance hardware disk then use EC2 instance store. Provides better I/O performance. Ephermeral storage – EC2 instance looses their storage if EC2 instances are stopped.

Elastic Block Store (EBS):

EBS is a network drive you can attach to your instances while they run. It allows your instances to persist data, even after their termination. They can only be mounted to one instance at a time (at the CCP level).

EBS – Delete on Termination attribute: if enabled, default EBS volume is lost and any other attached EBS volume is not deleted.

EBS Snapshot: Backup of EBS.

EBS Features are:

  • EBS Snapshot Archive: Move snapshot to “archive tier” that is cheaper.
  • Recycle Bin: Protect your Amazon EBS Snapshots and Amazon Machine Images (AMIs) from accidental deletion. Use Recycle Bin to protect your business critical EBS Snapshots and AMIs from accidental deletion. With Recycle Bin, you specify a configurable retention period within which you can recover these resources after they have been deleted.
  • Snapshots in the Recycle Bin incur the same charges as regular EBS Snapshots.

EBS Volume Type:

1) General Purpose SSD: gp2/gp3 (SSD), cost effective storage, low latency, 1GiB- 16TiB.

  1. Gp2: small gp2 volume can brust to 3000 IOPS. Size of volume and IOPS are limited. Max is 16000 IOPS.
  2. Gp3: Base line of 3000 IOPS & throughput of 125 MB/s. can increase IOPS upto 16000 and throughput upto 1000MB/s independently.

2) Provisioned IOPS SSD: io1/io2. Critical business application with sustained IOPS or application that needs more than 16000 IOPS. Great for database workload. It supports EBS-multi attach. Io1/io2 & io2 Block express.

Io1/io2 (4 GB – 16 TB): max provisioned IOPS=64000 for nitro instances and 32000 for other. Can increase IOPS independently from storage size. Io2 has more durability and more IOPS per GB with same price as io1.

3) Io2 Block Express: (4 GB – 64 TB) – sub millisecond latency and max IOPS= 256000

  1. Hard Drive Disk (HDD): can not be boot volume and 125GB to 16 GB only.
  2. Throughput Optimized(st1) – Big data, data warehouse, log processing etc. max throughput – 500 MB and 500 IOPS
  3. Cold HDD (sc1): for data that is infrequently used. Max throughput=250 MB, max IOPS=250 MB, scenarios where lowest cost is important.

Encrypt an unencrypted EBS Volume: 1) create EBS snapshot 2) Encrypt the EBS volume from snapshot 3) Now you can attach encrypted volume to instances.

Elastic File System:

EFS is Managed NFS (network file system) that can be mounted on 100s of EC2. EFS works with Linux EC2 instances in multi-AZ. EFS is highly available, scalable, expensive (3x gp2), pay per use, no capacity planning. EFS is managed NFS that can be mounted to many EC2.Uses NFSv4.1 protocol. POSIX file system. Storage class in EFS is cost-optimized way for files not accessed every day.

EFS Standard: standard EFS storage class.

EFS Infrequent Access (EFS-IA): EFS will automatically move your files to EFS-IA based on the last time they were accessed.

Top 13 Reasons to Why Learn AWS in 2022

Amazon Web Service – AWS Tutorial

How to connect to EC2 instance using SSH

What is Amazon EC2? – Amazon Elastic Compute Cloud