All notes

FIELD NOTES

EC2 Part 2

EC2 Instance Types

Instance Types

EC2 offers different instance types optimized for various use cases, following the naming convention:
Example: m5.2xlarge

  • m: Instance class
  • 5: Generation
  • 2xlarge: Size

Instance Categories

  • General Purpose: Balanced compute, memory, and networking, ideal for web servers and code repositories (Example: t2.micro).
  • Compute Optimized: High-performance processing for workloads like media transcoding, HPC, and gaming servers.
  • Memory Optimized: Fast performance for memory-intensive workloads such as databases and BI applications.
  • Storage Optimized: High sequential read/write access for OLTP, data warehouses, and distributed file systems.

Security: Security Groups

  • Control inbound and outbound traffic for EC2 instances.
  • Act as firewalls regulating access to ports, authorized IP ranges, and network control.
  • Important rules:
    • All inbound traffic is blocked by default.
    • All outbound traffic is allowed by default.
  • Common ports:
    • 22 (SSH) - Linux remote access
    • 80 (HTTP) - Unsecured websites
    • 443 (HTTPS) - Secured websites
    • 3389 (RDP) - Windows remote access

EC2 Purchasing Options

  • On-Demand: Pay-per-use (per second/hour), no long-term commitment.
  • Reserved Instances: 1 or 3-year contracts, lower costs.
  • Saving Plans: Usage commitment for discounts.
  • Spot Instances: Cheaper, but instances can be terminated anytime.
  • Dedicated Hosts: Entire physical server for better control.
  • Dedicated Instances: No shared hardware with other customers.
  • Capacity Reservations: Reserve capacity in a specific AZ.

On-Demand

  • Pay-as-you-go (per second/hour, depending on OS).
  • Highest cost, but no upfront payment or commitment.
  • Recommended for short-term and unpredictable workloads.

EC2 Storage

EBS - Elastic Block Store

An EBS Volume is a network drive that you can attach to your instances while they run.

Key Features

  • Persistent storage: Data remains even after instance termination.
  • Bound to an AZ: Cannot be moved between AZs without a snapshot.
  • Network-based: Some latency but can be detached and reattached quickly.
  • Provisioned capacity: Billed based on provisioned GB and IOPS.
  • Resizable: Can increase capacity over time.

Delete on Termination Attribute

  • Root volume: Deleted by default when instance is terminated.
  • Other volumes: Not deleted by default.
  • Can be modified: Through AWS console or CLI.

EBS Snapshots

  • Point-in-time backups of EBS volumes.
  • No need to detach the volume, but it's recommended.
  • Snapshots can be copied across AZs and Regions.

Features

  • EBS Snapshot Archive:
    • 75% cheaper storage tier.
    • Restore takes 24-72 hours.
  • Recycle Bin for EBS Snapshots:
    • Recover accidentally deleted snapshots.
    • Retention period from 1 day to 1 year.

AMI - Amazon Machine Image

  • Custom EC2 instance templates with software, OS, and configurations.
  • Region-specific but can be copied across regions.

AMI Sources

  1. Public AMI - AWS provided.
  2. Your own AMI - Created and maintained by you.
  3. AWS Marketplace AMI - Sold by third parties.

EC2 Image Builder

  • Automates EC2 AMI creation and maintenance.
  • Can be used for VMs or container images.

EC2 - Instance Store

  • High-performance local storage attached to EC2 instances.
  • Better I/O than EBS, but data is lost when the instance is stopped.
  • Good for: Buffering, caching, scratch data, temporary storage.
  • Risk: Data loss if hardware fails → backups are user responsibility.

EFS - Elastic File System

  • Managed NFS (Network File System) for multiple EC2 instances.
  • Multi-AZ, scalable, highly available, expensive (3x gp2).
  • Pay-per-use, no capacity planning required.

EFS vs. EBS

  • EBS → Single instance storage, must use snapshots for backup.
  • EFS → Shared storage across multiple instances.

EFS - Infrequent Access (EFS-IA)

  • Cost-optimized storage tier for less frequently accessed files.
  • Up to 92% lower cost than EFS Standard.
  • Lifecycle policy: Move files to EFS-IA automatically based on last access (e.g., after 60 days).

Shared Responsibility Model for EC2 Storage

AWS Responsibilities

  • Infrastructure maintenance.
  • Replication for EBS & EFS.
  • Hardware replacement.
  • Security (ensuring employees cannot access data).

User Responsibilities

  • Backup & snapshots setup.
  • Data encryption.
  • Managing stored data.
  • Understanding EC2 Instance Store risks.

Amazon FSx

  • Managed 3rd-party file systems on AWS.
  • FSx for Windows:
    • Fully managed Windows file system.
    • Supports SMB protocol & Windows NTFS.
    • Integrated with Active Directory.
    • Accessible from AWS or on-premise.

Amazon FSx for Lustre

  • High-performance file storage for HPC (High-Performance Computing).
  • Used for Machine Learning, Analytics, Video Processing, Financial Modeling.
  • Massively scalable:
    • 100s of GB/s throughput.
    • Millions of IOPS.
    • Sub-ms latency.