AWS EC2 Reference August 10, 2023 by Riston Leave a Comment Quickstart From the AWS Console, navigate to EC2. Then you will go to Instances, and select Launch Instances. From the “Launch an Instance” screen, you will perform the following actions: Name the instance Select the Amazon Machine Image/OS (Default is AWS Linux) Select the Instance Type (t2.micro is the default general EC2 type and is free tier eligible) Generate a new ssh key for remote access to server instance Configure Network Settings (set ssh access origins, http and https connections) Configure Storage (Sets the amount and type of Storage available in the instance) Advanced – (contains a field User Data which provisions a boot script) Launch Instance EC2 Types Naming Convention <instance_type><generation/version>.<size>(t2.micro) General Purpose Balanced between computing, network, and memory Good for most applications Compute Optimized Machine Learning Batch Processing Media Encoding/Transcoding Gaming Servers Memory Optimized Databases Cache Stores Real-time data processing Storage Optimized Databases and Warehousing Distributed File Systems High frequency online transaction processing (OLTP) systems Security Groups Operate as a firewall to specific EC2 instances, and many can be attached to a single instance. Both inbound and outbound rules can be configured based on port and ip address. Connection Strategies EC2 Instance Connect – Browser-based ssh connection (Security Group must allow connection) SSH – Must have .pem file and security groups configured. Purchasing Options On-Demand – Pay for what you use, billing per second after one minute – short term workloads Reserved (1 – 3 yrs) – Up to 72% less than on-demand, but requires a long term subscription. Savings (1 – 3 yrs) – Similar to above, commit to specific instance type Spot Instances – Up to 90% less than on demand, but can lose the instance if max amount is less than the current rate. These are great for failure resistant tasks like batch processing and data analysis. while (current spot price < max slot price)Spot Fleets – Set of spot instances and optional on-demand instances Dedicated Hosts – a physical server dedicated to your use; most expensive option. Dedicated Instances – runs on hardware dedicated to you, no control over placement. Capacity Reservations – reserved on demand instances you can access at any time. should be used with savings or reserved plans to maximize cost benefit. Placement Groups Cluster – clusters instances into low latency group in AZ Spread – across multiple underlying hardware (MAX 7 instances) Partition – across partitions (racks) in AZ – scales to 100s of instances. Elastic Network Interface (ENI) A virtual network card used with vpcs which enable EC2 instances to access the network. Can have 1 public IPv4 plus 1 or more private IPv4s One Elastic IP per private IPv4 One or more security groups One Mac address Can be created independently of EC2 instance https://aws.amazon.com/blogs/aws/new-elastic-network-interfaces-in-the-virtual-private-cloud/ Storage Options EBS – Elastic Block Store Overview EBS Volumes attach a network drive to an EC2 instance Allows instances to persist data, even after termination Can only be mounted one instance at a time (CCP Level) Bound to specific AZs Like a “Network USB stick” Free tier offers 30 GB of data storage in SSD or Magnetic per rmonth EBS Snapshots Create backups Archives – 75% cheaper, but can take up to three days to restore from Recycle Bin – Set period to retain deleted snapshots so that they can be restored (1day to 1 year) (FSR) Fast Snapshot Restore – expensive, but no latency on first use Volume Types gp2/gp3 – SSD Store balancing price and performance. io1/io2 – highest performance SSD volumes. Critical low-latency/high throughput. Provisioned IOPS (I/O Ops / Sec) – Critical Business applications, needs more than 16,000 4 GiB – 16TiB – io1/io2 4 GiB – 64 TiB – io2 Block Express (256,000 IOPS) Multi Attach to multiple (MAX 16) EC2 instances st1 – Low cost HDD for high frequency, intense throughput workloads. Can’t be a boot drive Throughput Optimized (Data Warehousing) sc 1 – Lowest cost HDD volume for less frequently accessed workloads Can’t be a boot drive Archived Data Encryption All data stored and moving between instance and volume is encrypted Minimal impact on latency Leverage keys from KMS/AES-256 Handled transparently To encrypt an unencrypted volume: Create EBS snapshot of volume Encrypt snapshot using copy Create new Volume from the snapshot Attach new encrypted volume to instance EFS – Elastic File System Managed NFS (Network File System) Can work in EC2 instances spanning multiple AZs Expensive, but highly available and scalable (3 x gp2) Useful for CMS, web serving, data sharing NSFv4.1 Only compatible with the Linux AMIs Performance Modes General Purpose – CMS, WordPress Max I/O – Media Processing – high latency, throughput, and parallel processing Throughput Mode Bursting – 1TB – 50MiB plus bursts up to 100MiB/s Provisioned – set regardless of storage size Elastic – scale based on workload Tiers Standard Infrequently Accessed (EFS-IA) – requires lifecycle policy Availability Standard – Prod, Multi-AZ One Zone – Dev, Single AZ