Amazon EC2: A Quick Summary

AWS EC2

AWS EC2

This blog is a part of my journey “Embarking on the AWS Solution Architect Associate SAA-CO3 Certification Journey”

Table of Content

  • Introduction
    • Introductory Points
  • Configuration Options
  • EC2 User Data
  • Instance Types
    • General
    • Compute Optimised
    • Memory Optimised
    • Storage Optimised
  • EC2 Instance Purchasing Options
    • On Demand Instances
    • Reserved Instances
    • Convertible Reserved Instances
    • Spot Instances
    • Dedicated Hosts
    • Dedicated Instances
  • EC2 Instance Saving Plans
  • EC2 Capacity Reservation
  • Spot Fleet
  • EC2 Placement group
    • Cluster
    • Spread
    • Partition
  • EC2 Hibernate
  • Conclusion

Introduction

Amazon Elastic Compute Cloud (EC2) is a foundational pillar of Amazon Web Services (AWS) that has revolutionized the way businesses deploy, manage, and scale their computing resources. EC2 offers a flexible and scalable cloud computing environment, allowing users to launch virtual machines (instances) in the cloud quickly and efficiently. With its diverse selection of instance types, customizable configurations, and pay-as-you-go pricing model, EC2 has become an indispensable tool for startups, enterprises, and developers worldwide. In this blog, we’ll explore the fundamental concepts of EC2, its key benefits, and real-world use cases, shedding light on why it remains a cornerstone of cloud computing infrastructure

Introductory Points

  1. Widespread Popularity: EC2 stands out as one of AWS’s most renowned services, cherished by a broad spectrum of users.
  2. Infrastructure as a Service (IaaS): EC2 falls under the category of Infrastructure as a Service, famously known as IaaS, and operates as the Elastic Compute Cloud within the AWS ecosystem.
  3. Versatile Capabilities: EC2 encompasses a diverse array of functionalities, including:
    1. Virtual Machine Rental: It offers the ability to lease virtual machines, referred to as EC2 instances.
    2. Data Storage: EC2 provides the means to store data on virtual drives through services like EBS (Elastic Block Store).
    3. Load Distribution: Load distribution across multiple machines is facilitated by services like ELB (Elastic Load Balancing).
    4. Scaling Flexibility: The service can seamlessly scale up or down by utilizing Auto Scaling Groups (ASG).

Configuration Options

  1. Operating System Choices: EC2 offers a variety of operating systems to choose from, including different versions of Linux, Windows, and macOS.
  2. Compute Power and Cores: Users have the flexibility to select the desired computational power and the number of CPU cores for their EC2 instances.
  3. RAM Customization: EC2 allows users to tailor their instances by specifying the amount of RAM that suits their requirements.
  4. Storage Allocation:
    • a. Storage Types: Users can decide between network-attached storage options like Elastic Block Store (EBS) and Elastic File System (EFS), or utilize hardware-based EC2 instance store storage.
    • Instance Store: EC2 instances also provide local, hardware-based storage options.
  5. Network Configuration:
    • Network Card: Users can specify the speed and capacity of the network card.
    • Public IP Address: Public IP addresses can be assigned to instances for internet accessibility.
  6. Security Group Settings: Security groups can be defined to control inbound and outbound traffic to and from EC2 instances, enhancing security.
  7. Bootstrap Scripts: EC2 instances can be configured with custom bootstrap scripts that execute during launch, allowing for automated setup and customization (referred to as EC2 User Data).

EC2 User Data

  • EC2 User Data provides the ability to bootstrap an instance by executing custom scripts during its initialization.
  • The User Data script runs only once when the instance is initially launched, and it operates with root-level privileges.
  • EC2 User Data serves as a powerful tool for automating essential boot tasks such as:
    • Installing system updates.
    • Deploying software packages.
    • Executing any necessary operations required during the initial bootup of the machine.

Instance Types

Within AWS, a vast array of EC2 instance types are available, each meticulously designed to address specific use cases by offering unique configurations.

  • AWS presents a diverse range of EC2 instance types, each tailored for specific use cases and optimized to deliver precise performance characteristics. AWS Instance Types
  • These instances adhere to a naming convention that includes three key elements: Eg. m5.2xlarge
    • Instance Class (e.g., ‘m’): Represents the general instance family.
    • Generation (e.g., ‘5’): Denotes the iteration or generation of the instance type, with AWS continually enhancing them.
    • Size (e.g., ‘2xlarge’): Specifies the specific size or capacity within the instance class.

For certification exams and practical AWS usage, it’s essential to grasp the distinctions among various instance types and comprehend their suitability for distinct scenarios.

Instance Type – General Purpose

  • Great for diversity of workloads such as webservers
  • The configuration are well balanced between Compute, Memory and Networking

Instance Type – Compute Optimised

  • Great for compute intensive tasks that require high performance processor
  • Use cases
    • Batch processing
    • Media Transcoding
    • High Performance Computing
    • Dedicated Gaming Servers

Instance Type – Memory Optimised

  • This instance is suitable for workloads which fast performance to process large datasets.
  • Use cases
    • High Performance Relational and Non Relational Database
    • Distributed web scale cache stores
    • In memory databases optimized for Business Intelligence

Instance Type – Storage Optimised

  • Great for storage instensive tasks that require high, sequential read and write to large data set in local storage.
  • Use case
    • High frequency online transaction processing (OLTP) systems.
    • Relational and Non SQL databases
    • Data warehousing application

EC2 Instance Purchasing Options

Amazon EC2 offers several purchasing options to cater to various workload and budget requirements.

On Demand Instances

  • Pay for what you use
    • Linux or Windows -> Billing per second, after the first minute
    • All other OS – Billing per hour
  • Has the highest cost, No upfront payment
  • No long term commitment
  • Recommended for short term and un-interrupted workloads, where you can’t predict how application will behave

Reserved Instances

  • As of today, Upto 70% discount compared to On-demand Instances
  • In this type, you reserve a specific attribute of the instance(Type, Region, tenancy, OS)
  • Reservation Period
    • 1 year (some discount)
    • 3 years (more discount)
  • Payment Option
    • No Upfront (+ Discount)
    • Partial Upfront (++ Discount)
    • All Upfront (+++ Discount)
  • Reserve Instance Scope
    • Regional
    • Zonal
  • Recommended for steady state usage application (Database)
  • You can Buy & Sell these instances in Reserved Instance Marketplace

Convertible Reserved Instances

  • This follows same principle as Reserved Instance with one additional feature
  • We can change the EC2 Instance type, instance family, OS, scope and tenancy
  • Up to 66% Discount

Spot Instances

  • Spot Instances allow you to bid on spare AWS EC2 capacity, providing substantial cost savings if your applications can be interrupted or have flexible start times.
  • Upto to 90% Discount
  • These Instances can be lost if at any point of time your bid amount is less than current spot price.
  • The most cost effective instances in AWS
  • Useful for the workloads that are resilient to fault tolerence
    • Batch Jobs
    • Data Analysis
    • Image processing
    • Workload with flexible start and end time
  • Not suitable for critical jobs

Dedicated Hosts

  • Dedicated Hosts enable you to have physical servers dedicated exclusively to your use, which can help meet compliance and licensing requirements. They are typically used for applications with specific host-level requirements.
  • Allows you to address compilance requirements and use your existing server bound software licences
  • Purchasing Options
    • On Demand
    • Reserved – 1 or 3 years, with payment option (No upfront, Partial upfront, full upfront)
  • This is the most expensive instance available in AWS

Dedicated Instances

  • Dedicated Instances run on hardware that’s isolated for your use but without the need to manage the physical host. They are suitable for workloads that require instance-level isolation.
  • Instance run on hardware that dedicated to you
  • May share hardware with other instance in same account
  • No control over instance placement

EC2 Instance Saving Plans

  • Savings Plans offer significant savings over On-Demand Instances, just like EC2 Reserved Instances, in exchange for a commitment to use a specific amount of compute power (measured in $/hour) for a one or three-year period
  • Get a discount based on long term usage (1 or 3 years)
  • Usage beyond the savings plan is billed at on Demand price
  • Locked to a specific instance family & AWS region
  • Flexible across
    • Instance Size
    • OS
    • Tenancy

EC2 Capacity Reservation

  • Reserve On-demand instance capacity in a specific AZ for any duration
  • You always have access to EC2 capacity when you need it
  • No time commitment, no billing discounts
  • Combine with regional reserved instances and saving plans to benefit from discounts
  • You are charged at On-Demand rate whether you run instance or not
  • Suitable for short term, uninterrupted workload that needs to be in a specific AZ

Spot Fleet

  • Spot fleet is a feature provided by AWS for managing Spot Instances by automatically launching and maintaining the desired number of instances based on your defined capacity requirements, while also allowing you to take advantage of cost savings.
  • Spot Fleet = Set of Spot Instances + On-Demand Instance (Optional)
  • The Spot Fleet will try to meet the target capacity with price constraint
    • Define possible launch pools: Instance Type, OS, AZ
    • Spot Fleet can have multiple launch pools to choose from.
  • Strategies to allocate Spot Instances.
    • Lowest Price: From the pool pick the instance with lowest price (Cost optimised, short workload)
    • Diversified: Distributed across all pools (Great for availability, long work loads)
    • Capacity Optimised: Pool with the optimal capacity for number of instance
    • Price and Capacity Optimised: Selects pools with highest capacity, then select pool with lowest price

EC2 Placement group

  • At times, you may need precise control over how your EC2 Instances are placed.
  • These strategies for placement can be established using something known as a “placement group.”
  • When you create a placement group, you specify one of the following strategies for the group:
    • Cluster: This strategy clusters instances together in a single Availability Zone, optimizing for low-latency communication within the group.
    • Spread: It distributes instances across different underlying hardware to enhance fault tolerance (limited to seven instances per group per Availability Zone).
    • Partition: This strategy scatters instances across numerous partitions, each relying on distinct sets of racks within an Availability Zone, allowing for scaling to hundreds of EC2 instances per group.

Placement Group – Cluster

  • All the instances are placed under same Rack in a same AZ
  • Pros:
    • Great Network (10Gbps bandwidth between instance)
  • Cons:
    • Single Point of Failure, If the rack fails all the instance fails at the same time
  • Use case:
    • Big Data jobs that needs to compute fast
    • Application that needs extremely low latency and high network throughput.

Placement Group – Spread

  • Instances are distributed across AZs on different physical hardwarers
  • Pros:
    • Reduce risk of simultaneous failure
  • Cons:
    • Limited to 7 Instances per AZ per placement group
  • Use case:
    • Application that needs to maximize high availability
    • Critical Applications where each instances must be isolated from failure

Placement Group – Partition

  • In the context of AWS, a “Partition” essentially refers to a rack within an AWS data center.
  • it can span across multiple Availability Zones (AZs) within the same region.
  • Pros:
    • We can run upto 100s EC2
    • A partition failure only effects the EC2 in that partition, other instances will be running safely
  • Use case:
    • HDFS
    • Hbase
    • Kafka
    • Cassandra

EC2 Hibernate

  • Introduction
    • In EC2 Hibernate, the In- memory state is preserved
    • The instance boot is much faster
    • Under the hood, the RAM state is written to a file in the root EBS volume.
    • The root EBS volume must be encrypted
  • Use cases:
    • Long-running processes that need to retain their state.
    • Saving the volatile RAM state of an instance.
    • Services that have lengthy initialization processes, as it expedites the startup.
  • Conditions
    • Instance RAM Size should be less than 150GB
    • Not supported for bare metal instances
    • Root volume must be EBS and encrypted
    • Available for On Demand, Reserved and Spot Instances
    • Hibernate not more than 60 days

Conclusion

In conclusion, Amazon Elastic Compute Cloud (EC2) is the backbone of AWS, offering a wide array of instance types and configurations to meet diverse computing needs. Throughout this blog, we’ve explored EC2’s foundational concepts, key features, instance types, and best practices.

EC2 empowers businesses to scale effortlessly, whether you’re launching a small web application or deploying a complex, high-performance cluster. Its flexibility, reliability, and cost-effectiveness make it an indispensable resource for organizations worldwide.

By understanding EC2’s pricing models, security considerations, and deployment options, you can harness the full potential of AWS for your workloads.

Related Post