본문 바로가기
AWS Solutions Architect Associate 자격증

Section 5 : EC2 Fundamentals_part 2

by Jackykim 2023. 7. 23.

EC2 Instances Purchasing options
- On-demand Instances – short workload, predictable pricing, pay by second
- Reserved (1 & 3 years)

Reserved Instances – long workloads

Convertible Reserved Instances – long workloads with flexible instances

- Savings Plans (1 & 3 years) –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

 

For Ec2 on Demand
- Pay for what you use
- Has the highest cost but no upfront costs
- no long term commitment
- Recommended for short term and un-interrupted workloads, where you cant predicts how the application will behave.

 

EC2 Reserved Instances
- Discount compared to on-demand
- reserve a specific instance attributes
- reservation period -> 1 year / 3 years
- payment options -> no upfront, partial upfront, all upfront
- Reserved instance’s scope
- recommended for steady usage
- you can sell and buy in the reserved instance marketplace
- convertible reserved instance

 

EC2 savings plan
- Get 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 and AWS region
- Flexible across : instance size, OS, Tenancy

 

EC2 Spot Instances
- Can get a discount up to 90% compared to on demand
- Instances that you can lose at any point of time if your max price is less than the current spot price
- Most cost efficient instances in AWS
- Useful for workloads that are resilient to failure : batch jobs, data analysis, image processing, distributed workloads, workloads with a flexible start and end time
- Not suitable for critical jobs or databases

 

EC2 Dedicated Hosts
- A physical server with EC2 instance capacity fully dedicated for use
- Allows you address compliance requirements and use your existing server- bound software licenses (per-socket, per-core, pe—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)

- The most expensive option

- Useful for software that have complicated licensing model (BYOL – Bring Your Own License)

- Or for companies that have strong regulatory or compliance need

 

EC2 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

EC2 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, uninterrupted workloads that needs to be in a

specific AZ


Which purchasing option is right for me?
- 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 (e.g.,

King, Suite, Sea View, …)

- 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

 

* Exam will ask if you know which type of instances is the right one

 

EC2 Spot Instances requests
- Can get discounts compared to om demand
- Define max spot prices and get the instance while current spot price < max
 - The hourly spot price varies based on offer and capacity
 - If the current spot price > your max price you can choose to stop or terminate your instance with a 2 min grace period
- Spot block : block spot instance during a specified time frame without interruptions
- In rare situations the instance may be reclaimed.

 

How to terminate spot instances?

- You can only cancel spot instance requests that are open, active or disabled
- Cancelling a spot request does not terminate instances
- You must first cancel a spot request, and then terminate the associated spot instances

 

Spot Fleets
- Spot Fleets = set of Spot Instances + (optional) On-Demand Instances

- The Spot Fleet will try to meet the target capacity with price constraints

Define possible launch pools: instance type (m5.large), OS, Availability Zone

Can have multiple launch pools, so that the fleet can choose

Spot Fleet stops launching instances when reaching capacity or max cost

- Strategies to allocate Spot Instances:

lowestPrice: from the pool with the lowest price (cost optimization, short workload)

diversified: distributed across all pools (great for availability, long workloads)

capacityOptimized: pool with the optimal capacity for the number of instances

- Spot Fleets allow us to automatically request Spot Instances with the lowest price

 

EC2 Instances Launch types hands on
- Go to EC instances -> spot instances -> Create spot instances / spot fleet
- Some attributes can be chosen while some can be specified
- You can choose multiple instances for diverse pool and check the costs and how strong the fleet is.
- To launch a spot instance directly -> Go to launch instance -> Advanced details -> check request spot instances under purchasing option
 - The max price is automatically set at on demand but can be changed

For Reserved instances
- Go to instances and choose reserved instances -> purchase reserved instances -> add to cart

EC2 Fundamental questions
Q1 Which EC2 Purchasing option can provide you the biggest discount, but it is not suitable for critical jobs or databases?
A: Convertible reserved instances
B: Dedicated Hosts
C: Spot instances

Q2 What should you use to control traffic in and out of EC2 instances?
A: Network Access Control List (NACL)
B: Security Groups
C: IAM policies

 

Q3 How long can you reserve an EC2 reserved instance?
A: 1 or 3 years
B: 2 or 4 years
C: 6 months or 1 year
D: anytime between 1 and 3 years

 

Q4 You would like to deploy a High-Performance Computing (HPC) application on EC2 instances. Which EC2 instance type should you choose?
A: Storage optimized
B: Compute optimized
C: Memory optimized
D: General purpose

Q5 Which EC2 Purchasing Option should you use for an application you plan to run on a server continuously for 1 year?
A: Reserved Instances
B: Spot instances
C: On-Demand instances

 

Q6 You are preparing to launch an application that will be hosted on a set of EC2 instances. This application needs some software installation and some OS packages need to be updated during the first launch. What is the best way to achieve this when you launch the EC2 instances?
A: Connect to each EC2 instance using SSH, then install the required software and update your OS packages manually
B: Write a bash script that installs the required software and updates to your OS, then contact AWS support and provide them with the scripts. They will run it on your EC2 instances at launch
C: Write a bash script that installs the required software and updates to your OS, then use this script in EC2 user data when you launch your EC2 instances (EC2 User Data is used to bootstrap your EC2 instances using a bash script. This script can contain commands such as installing software/packages, download files from the Internet, or anything you want.)

Q7 Which EC2 Instance Type should you choose for a critical application that uses an in-memory database?
A: Compute optimized
B: Storage optimized
C: Memory optimized
D: General purpose

 

Q8 You have an e-commerce application with an OLTP database hosted on-premises. This application has popularity which results in its database has thousands of requests per second. You want to migrate the database to an EC2 instance. Which EC2 Instance Type should you choose to handle this high-frequency OLTP database?
A: Compute optimized
B: Storage optimized
C: Memory optimized
D: General purpose

 

Q9 Security Groups can be attached to only one EC2 instance.
A: False (Security Groups can be attached to multiple EC2 instances within the same AWS Region/VPC.)
B: True

Q10 You're planning to migrate on-premises applications to AWS. Your company has strict compliance requirements that require your applications to run on dedicated servers. You also need to use your own server-bound software license to reduce costs. Which EC2 Purchasing Option is suitable for you?
A: Convertible reserved instances
B: Dedicated Hosts
C: Spot instances

Q11 You would like to deploy a database technology on an EC2 instance and the vendor license bills you based on the physical cores and underlying network socket visibility. Which EC2 Purchasing Option allows you to get visibility into them?
A: Spot Instances
B: On-demand
C: Dedicated Hosts
D: Reserved instances