skip to Main Content

AWS EC2

EC2 = Elastic Compute Cloud
Compute capacity in the cloud
Allows you to quickly scale capacity up and down
Virtual Machines in the cloud
Pay only for capacity you actually use

NOTE: Root volumes by default are deleted when terminated!  Data on any other EBS volume persists after instance termination
API call in final process of creating an AMI = RegisterImage
AMI = Amazon Machine Image
AMI to describe image = DescribeImages

EC2 Options:

  • On Demand – pay fixed rate by the hour or second – no commitment
    • Apps with short term or unpredictable workloads
    • Apps being developed or tested
  • Reserved – capacity reservation 1 to 3 years
    • Apps with steady state or predictable usage
    • User pays upfront to reduce computing costs
  • Spot – bid whatever price you want for instance capacity
    • Apps with flexible start / end times
  • Dedicated Hosts – physical EC2 server dedicated for your use
    • Regulatory requirements that may not support multi tenant virtualization

Instance types – remember DRMCGIFTPX
D2 – Dense storage – Files Servers / Data Warehousing / Hadoop
R4 – Memory think R for RAM – memory intensive – Apps / Database
M4 – General purpose – App server – think main choice
C4 – compute optimized – cpu intensive APPS / Databases
G2 – Graphic Intensive – Video Encoding / 3D app streaming
I2 – High Speed Storage (high IOPS) – NoSQL DBs, Data Warehousing
F1 – Field Programmable Gate Array – Hardware acceleration for your code
T2 – Lowest cost, General Purpose – Web Servers / Small DBs
P2 – Graphics / General Purpose GPU – Machine learning, Bit Coin Mining etc – think PICS
X1 – Memory Optimized – SAP HANA / Apache Spark etc

EBS – Elastic Block Storage provides persistent block storage volumes for use with EC2 instances.
EBS backed instances can be stopped and started – Instance store-backed cannot
You cannot mount 1 EBS volume to multiple EC2 instances, to do this use EFS (Elastic File System)

  1. General purpose SSD (gp2) – up to 10K IOPS.  Use case boot volumes, low-latency interactive apps, dev & test
  2. Provisioned IOPS SSD (io1) – Highest performance SSD volume.  I/O intensive NoSQL and relational databases
  3. HDD (st1) – low cost HDD – Big data, data warehouses, log processing – CANNOT be boot volume
  4. Cold HDD (sc1) lowest cost HDD – colder data requiring fewer scans per day – no boot volume
  5. Magnetic (standard) – cold hard disk drive – low cost can be boot volume

EC2 instance needs to be in the same availability zone as EBS volume
To move EBS volmues from one AZ to another you need to create a snapshot first and then you can change AZ.
Snapshots are point in time copies of volume and exist on S3.  Snaps are incremental only the blocks that have changed since last snapshot are moved to S3
To create snapshot for EBS volume that serve as a root device you should stop the instance before taking the snapshot
You can create AMIs from both volumes and snapshots
You can change EBS volume size on the fly

EFS – Elastic File System

File storage service – is elastic, growing and shrinking automatically as you add and remove files

You can mount your Amazon EFS file systems on your on-premises datacenter servers when connected to your Amazon VPC with AWS Direct Connect. You can mount your EFS file systems on on-premises servers to migrate data sets to EFS, enable cloud bursting scenarios, or backup your on-premises data to EFS.

Only pay for storage used
Multiple AZ’s within a region
Block based storage
Can be shared with other EC2 instances
Can be in one instance with load balances so you have 2 or more web servers.
Perfect for file server

More notes:

Instance Store-backed Instances – root device volume – any data on here persists as long as the instance is running, but data is deleted when instance is terminated (doesn’t support the stop)
EBS-backed Instances – can be stopped and restarted without affecting data stored on the attached volumes

To attach volume API = AttachVolume

To write data to DynamoDB table from EC2 instance – Create an IAM role that allows write access to the DynamoDB table and attach to instance

EBS – secure data on EBS volume – use an encrypted file system on top of EBS volume

EBS – Size limit of Amazon Instance store backed AMI’s – 10 GB
EBS – Size limit of EBS-backed instance is 16TB

EC2 best practice to create a role IAM to run code

AMI’s can be shared with account ID – don’t need to be public

API to call to bundle Amazon Instance Store-backed – BundleInstance

EBS backed kernel, ram disk, and user data can be changed when stopped!  Instance store-backed instance attributes are fixed for life on an instance

Back To Top