Note
•
EC2 (Elastic Compute Cloud)
•
•
What is EC2
•
EC2 = Elastic Compute Cloud = Infrastructure as a Service
•
It mainly consists in the capability of:
◦
Renting virtual machines (EC2)
◦
Storing data on virtual drives (EBS)
◦
Distributing load across machines (ELB)
◦
Scaling the services using an auto-scaling group (ASG)
EC2 sizing & configuration options
•
Operating System (OS): Linux, Windows or Mac OS
•
How much compute power & cores (CPU)
•
How much random-access memory (RAM)
•
How much storage space:
◦
Network-attached (EBS & EFS)
◦
Hardware (EC2 Instance Store)
◦
Network card: speed of the card, Public IP address
◦
Firewall rules: security group
•
Bootstrap script (configure at first launch): EC2 User Data
EC2 User Data
•
It is possible to bootstrap our instances using an EC2 User data script
•
Bootstrapping means launching commands when a machine starts
•
That script is only run once at the instance first start
•
EC2 user data is used to automate the Boot tasks such as:
◦
Installing updates
◦
Installing software
◦
Downloading common files from the internet
◦
Anything you can think of
•
The EC2 User Data Script runs with the root user: sudo
EC2 Instance Types
•
EC2 mainly has 4 instance types
◦
General Purpose
◦
Compute Optimized (C)
◦
Memory Optimized (R)
◦
Storage Optimized
General Purpose
•
Great for a diversity of workloads such as web servers or code repositories
•
Balance between:
◦
Compute
◦
Memory
◦
Networking
•
In the course, we will be using the t2.micro which is a General Purpose EC2 instance
Compute Optimized (C)
•
Great for compute-intensive tasks that require high performance processors
◦
Batch processing workloads
◦
Media transcoding
◦
High performance web servers
◦
High performance computing (HPC)
◦
Scientific modeling & machine learning
◦
Dedicated gaming servers
Memory Optimized (R)
•
Fast performance for workloads that process large data sets in memory
•
Use cases
◦
High performance, relational/non-relational databases
◦
Distributed web scale cache stores
◦
In-memory databases optimized for BI (business intelligence)
◦
Applications performing real-time processing of big unstructured data
Storage Optimized
•
Great for storage-intensive tasks that require high, sequential read and write access to large data sets on local storage
•
Use cases:
◦
High frequency online transaction processing (OLTP) systems
◦
Relational & NoSQL databases
◦
Cache for in-memory databases (for example, Redis)
◦
Data warehousing applications
◦
Distributed file systems
EC2 Instances
•
On-Demand Instances - short workload, predictable pricing, pay by second
•
Reserved Instances
◦
Reserved Instances - long workloads
◦
Convertible Reserved Instances - long workloads with flexible instances
•
Savings Plans - commitment to an amount of usage, long workload
•
Spot Instances - short workloads, cheap, can lose instances (less reliable)
•
Dedicated Hosts - book an entire physical server, control instance placement
•
Dedicated Instances - no other customers will share your hardware
•
Capacity Reservations - reserve capacity in a specific AZ for any duration
EC2 Purchasing Options
•
On demand: coming and staying in resort whenever we like, we pay the full price
•
Reserved: like planning ahead and if we plan to stay for a long time, we may get a good discount
•
Savings Plans: pay a certain amount per hour for certain period and stay in any room type
•
Spot instances: the hotel allows people to bid for the empty rooms and the highest bidder keeps the rooms. You can get kicked out at any time
•
Dedicated Hosts: We book an entire building of the resort
•
Capacity Reservations: you book a room for a period with full price even you don’t stay in it
On-Demand Instances
•
Has the highest cost but no upfront payment
•
No long-term commitment
•
Recommended for short-term and un-interrupted workloads, where you can’t predict how the application will behave
Reserved Instances
•
Reserve a specific instance attributes
•
Reservation Period = 1 year or 3 years
•
Payment Options - No Upfront, Partial Upfront, All Upfront
•
Reserved Instance’s Scope - Regional or Zonal
•
Recommended for steady-state usage applications (like database)
•
Can buy and sell in the Reserved Instance Marketplace
•
Convertible Reserved Instance
◦
Can change the EC2 instance type, instance family, OS, scope and tenancy
Savings Plans
•
Get a discount based on long-term usage
•
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
◦
OS
◦
Tenancy
Spot Instances
•
The MOST cost-efficient instances in AWS
•
Instances that can lose at any point of time if your max price is less than the current spot price
•
Useful for workloads that are resilient to failure
◦
Batch jobs
◦
Data analysis
◦
Image processing
◦
Any distributed workloads
◦
Workloads with a flexible start and end time
•
Not suitable for critical jobs or databases
Dedicated Hosts
•
The MOST expensive option
•
A physical server with EC2 instance capacity fully dedicated to the personal use
•
Allows to address compliance requirements and use your existing server-bound software licenses (per-socket, per-core, per-VM software licenses)
•
Purchasing Options:
◦
On-demand - pay per second for active Dedicated Host
◦
Reserved - 1 or 3 years (No Upfront, Partial Upfront, All Upfront)
•
Useful for software that have complicated licensing model (BYOL - Bring Your Own License)
•
Or for companies that have strong regulatory or compliance needs
Dedicated Instances
•
Instances run on hardware that’s dedicated to you
•
May share hardware with other instances in same account
•
No control over instance placement (can move hardware after Stop / Start)
Characteristic | Dedicated
Instances | Dedicated
Hosts |
Enables the use of dedicated physical servers | X | X |
Per instance billing (subject to a $2 per region fee) | X | |
Per host billing | X | |
Visibility of sockets, cores, host ID | X | |
Affinity between a host and instance | X | |
Targeted instance placement | X | |
Automatic instance placement | X | X |
Add capacity using an allocation request | X |
Capacity Reservations
•
Reserve On-Demand instances capacity in a specific AZ for any duration
•
You always have access to EC2 capacity when you need it
•
No time commitment (create/cancel anytime), no billing discounts
•
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, uniterrupted workloads that needs to be in a specific AZ


.png&blockId=4d5d7c30-0f86-4516-ba16-562ce2160382)
.png&blockId=4d5d7c30-0f86-4516-ba16-562ce2160382&width=256)