Appearance
Amazon EC2 — Theory (Bản gốc slide / Original slide)
1. EC2 là gì (What is EC2)
- EC2 = Elastic Compute Cloud = Infrastructure as a Service (IaaS)
- Là một trong những dịch vụ phổ biến nhất của AWS
- Nắm vững EC2 là nền tảng để hiểu cách Cloud hoạt động
- Chủ yếu bao gồm khả năng:
- Thuê máy ảo (EC2)
- Lưu trữ dữ liệu trên ổ đĩa ảo (EBS)
- Phân phối tải giữa các máy (ELB)
- Tự động mở rộng quy mô dịch vụ (ASG — Auto Scaling Group)
- EC2 = Elastic Compute Cloud = Infrastructure as a Service
- One of the most popular AWS offerings
- Knowing EC2 is fundamental to understanding how the Cloud works
- It mainly consists of 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)
2. Các tùy chọn cấu hình & sizing (EC2 Sizing & Configuration Options)
Khi tạo một EC2 instance, ta có thể cấu hình:
- Hệ điều hành (OS): Linux, Windows, hoặc Mac OS
- Sức mạnh tính toán & số lõi (CPU)
- Bộ nhớ truy cập ngẫu nhiên (RAM)
- Dung lượng lưu trữ:
- Network-attached: EBS & EFS
- Phần cứng: EC2 Instance Store
- Network card: tốc độ card, địa chỉ Public IP
- Firewall rules: Security Group
- Bootstrap script (cấu hình lúc khởi động đầu tiên): EC2 User Data
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
3. EC2 User Data
- Có thể bootstrap instance bằng một EC2 User Data script
- bootstrapping nghĩa là chạy các lệnh ngay khi máy khởi động
- Script này chỉ chạy một lần duy nhất, ở lần khởi động đầu tiên của instance
- EC2 User Data thường dùng để tự động hoá các tác vụ lúc boot, ví dụ:
- Cài đặt update
- Cài đặt phần mềm
- Tải các file phổ biến từ Internet về
- Bất kỳ việc gì bạn nghĩ ra
- EC2 User Data script chạy với quyền root user
- 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's first start
- EC2 user data is used to automate 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
4. EC2 Instance Types — Tổng quan (Overview)
- Có nhiều loại EC2 instance khác nhau, được tối ưu cho từng use case (xem danh sách)
- AWS dùng quy ước đặt tên như sau:
m5.2xlarge- m: instance class
- 5: generation (AWS cải tiến theo thời gian)
- 2xlarge: size trong instance class đó
- You can use different types of EC2 instances that are optimised for different use cases (see list)
- AWS has the following naming convention:
m5.2xlarge- m: instance class
- 5: generation (AWS improves them over time)
- 2xlarge: size within the instance class
5. EC2 Instance Types — General Purpose
- Phù hợp cho nhiều loại workload đa dạng như web server hoặc code repository
- Cân bằng giữa: Compute, Memory, Networking
- Trong khoá học sẽ dùng
t2.micro— một General Purpose EC2 instance - Danh sách instance type sẽ thay đổi theo thời gian, hãy kiểm tra trang AWS để có thông tin mới nhất
- 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.microwhich is a General Purpose EC2 instance - This list will evolve over time, please check the AWS website for the latest information
6. EC2 Instance Types — Compute Optimized
Phù hợp cho các tác vụ cần nhiều compute, yêu cầu processor hiệu năng cao:
- Batch processing workloads
- Media transcoding
- Web server hiệu năng cao
- High performance computing (HPC)
- Scientific modeling & machine learning
- Dedicated gaming servers
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
7. EC2 Instance Types — Memory Optimized
- Hiệu năng nhanh cho các workload xử lý tập dữ liệu lớn trong memory
- Use case:
- Database (relational/non-relational) hiệu năng cao
- Distributed web scale cache store
- In-memory database tối ưu cho BI (business intelligence)
- Ứng dụng xử lý real-time trên dữ liệu lớn, không có cấu trúc (unstructured)
- 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
8. EC2 Instance Types — Storage Optimized
- Phù hợp cho tác vụ nặng về storage, cần đọc/viết tuần tự (sequential) với tốc độ cao trên tập dữ liệu lớn ở local storage
- Use case:
- Hệ thống OLTP (online transaction processing) tần suất cao
- Database relational & NoSQL
- Cache cho in-memory database (ví dụ Redis)
- Ứng dụng data warehousing
- Distributed file system
- 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
9. EC2 Instance Types — Ví dụ (Example)
Vài ví dụ minh hoạ sự khác biệt giữa các loại instance:
A few examples illustrating the difference between instance types:
| Instance | vCPU | Mem (GiB) | Storage | Network Performance | EBS Bandwidth (Mbps) |
|---|---|---|---|---|---|
| t2.micro | 1 | 1 | EBS-Only | Low to Moderate | — |
| t2.xlarge | 4 | 16 | EBS-Only | Moderate | — |
| c5d.4xlarge | 16 | 32 | 1 x 400 NVMe SSD | Up to 10 Gbps | 4,750 |
| r5.16xlarge | 64 | 512 | EBS Only | 20 Gbps | 13,600 |
| m5.8xlarge | 32 | 128 | EBS Only | 10 Gbps | 6,800 |
Trang tra cứu hữu ích: instances.vantage.sh
Great website: instances.vantage.sh
10. Giới thiệu Security Groups (Introduction to Security Groups)
- Security Group là nền tảng cơ bản của network security trong AWS
- Chúng kiểm soát traffic được cho phép vào (inbound) hoặc ra (outbound) khỏi EC2 Instance
- Security group chỉ chứa rules (không chứa Deny, chỉ có Allow)
- Rule của security group có thể tham chiếu theo IP hoặc theo security group khác
- Security Groups are the fundamental of network security in AWS
- They control how traffic is allowed into or out of our EC2 Instances
- Security groups only contain rules
- Security groups rules can reference by IP or by security group
11. Security Groups — Đi sâu hơn (Deeper Dive)
Security group hoạt động như một "firewall" trên EC2 instance, điều chỉnh:
- Quyền truy cập vào Port
- Authorised IP ranges — cả IPv4 và IPv6
- Kiểm soát inbound network (từ nơi khác đến instance)
- Kiểm soát outbound network (từ instance đi ra nơi khác)
Security groups are acting as a "firewall" on EC2 instances. They regulate:
- Access to Ports
- Authorised IP ranges — IPv4 and IPv6
- Control of inbound network (from other to the instance)
- Control of outbound network (from the instance to other)
12. Security Groups — Sơ đồ (Diagram)
EC2 InstanceIP XX.XX.XX.XX
Security Group 1 · InboundFilter IP / Port with Rules
Port 22Your ComputerIP XX.XX.XX.XX · authorised port 22
Port 22Other computernot authorised port 22
Security Group 1 · OutboundFilter IP / Port with Rules
Any PortWWWAny IP – Any Port
- Inbound: traffic từ máy tính của bạn (IP
XX.XX.XX.XX, port 22) được Security Group 1 cho phép vào EC2 instance vì rule inbound khớpIP XX.XX.XX.XX+port 22. Một máy khác không nằm trong rule sẽ không được phép truy cập port 22 - Traffic từ Internet (WWW) trên các IP/port khác chỉ vào được nếu có rule inbound tương ứng cho phép
- Outbound: mặc định EC2 instance được phép gửi traffic ra
Any IP–Any Port(trừ khi rule outbound bị giới hạn lại)
- Inbound: traffic from your computer (IP
XX.XX.XX.XX, port 22) is allowed into the EC2 instance because Security Group 1's inbound rule matchesIP XX.XX.XX.XX+port 22. Another computer not covered by the rule is not authorised to reach port 22 - Traffic from the Internet (WWW) on other IPs/ports only gets in if a matching inbound rule allows it
- Outbound: by default the EC2 instance is allowed to send traffic to
Any IP–Any Port(unless the outbound rule restricts it)
13. Security Groups — Điều cần biết (Good to Know)
- Có thể gắn (attach) vào nhiều instance
- Bị giới hạn (locked down) theo cặp region / VPC
- "Sống" ở ngoài EC2 — nếu traffic bị chặn, EC2 instance sẽ không thấy traffic đó
- Nên duy trì một security group riêng cho SSH access
- Nếu ứng dụng không truy cập được (time out) → thường là do security group
- Nếu ứng dụng trả lỗi "connection refused" → thường là do lỗi ứng dụng hoặc ứng dụng chưa chạy
- Toàn bộ inbound traffic bị chặn theo mặc định
- Toàn bộ outbound traffic được cho phép theo mặc định
- Can be attached to multiple instances
- Locked down to a region / VPC combination
- Does live "outside" the EC2 – if traffic is blocked the EC2 instance won't see it
- It's good to maintain one separate security group for SSH access
- If your application is not accessible (time out), then it's a security group issue
- If your application gives a "connection refused" error, then it's an application error or it's not launched
- All inbound traffic is blocked by default
- All outbound traffic is authorised by default
14. Tham chiếu security group khác (Referencing Other Security Groups)
EC2 InstanceIP XX.XX.XX.XX
Security Group 1 · InboundAuthorising Security Group 1 · Authorising Security Group 2
Port 123Security Group 2 (attached)EC2 Instance · IP XX.XX.XX.XX
Port 123Security Group 1 (attached)EC2 Instance · IP XX.XX.XX.XX
Port 123Security Group 3 (attached)EC2 Instance · IP XX.XX.XX.XX
- Một rule inbound có thể authorise trực tiếp một security group khác (thay vì một IP CIDR) làm nguồn traffic
- Ví dụ: Security Group 1 (SG1) mở inbound port 123 và authorise traffic đến từ instance thuộc SG1 hoặc SG2
- Nhờ đó, các instance thuộc SG1/SG2 gọi nhau qua port 123 được cho phép, dù IP của các instance có thể thay đổi (auto-scaling, restart...) — không cần cập nhật rule theo IP mỗi lần
- Instance thuộc SG3 không được authorise nên sẽ không gọi được vào port 123
- An inbound rule can directly authorise another security group (instead of an IP CIDR) as the traffic source
- Example: Security Group 1 (SG1) opens inbound port 123 and authorises traffic coming from instances that belong to SG1 or SG2
- This means instances in SG1/SG2 can call each other on port 123 even if their IPs change (auto-scaling, restarts...) — no need to update rules by IP each time
- An instance that belongs only to SG3 is not authorised, so it cannot reach port 123
15. Các port kinh điển cần biết (Classic Ports to Know)
- 22 = SSH (Secure Shell) — đăng nhập vào Linux instance
- 21 = FTP (File Transfer Protocol) — upload file vào file share
- 22 = SFTP (Secure File Transfer Protocol) — upload file qua SSH
- 80 = HTTP — truy cập website không bảo mật
- 443 = HTTPS — truy cập website bảo mật
- 3389 = RDP (Remote Desktop Protocol) — đăng nhập vào Windows instance
- 22 = SSH (Secure Shell) - log into a Linux instance
- 21 = FTP (File Transfer Protocol) – upload files into a file share
- 22 = SFTP (Secure File Transfer Protocol) – upload files using SSH
- 80 = HTTP – access unsecured websites
- 443 = HTTPS – access secured websites
- 3389 = RDP (Remote Desktop Protocol) – log into a Windows instance
16. Các tuỳ chọn mua EC2 Instance (EC2 Instances Purchasing Options)
- On-Demand Instances — workload ngắn, giá dự đoán được, trả theo giây
- Reserved (1 & 3 năm)
- Reserved Instances — workload dài hạn
- Convertible Reserved Instances — workload dài hạn nhưng cần linh hoạt đổi loại instance
- Savings Plans (1 & 3 năm) — cam kết một mức usage, workload dài hạn
- Spot Instances — workload ngắn, rẻ, có thể mất instance bất cứ lúc nào (kém tin cậy)
- Dedicated Hosts — thuê nguyên một physical server, kiểm soát được vị trí đặt instance
- Dedicated Instances — không có customer nào khác dùng chung hardware với bạn
- Capacity Reservations — đặt trước capacity ở một AZ cụ thể, trong khoảng thời gian bất kỳ
- 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
17. EC2 On-Demand
- Trả tiền theo mức dùng thực tế:
- Linux hoặc Windows — tính phí theo giây, sau phút đầu tiên
- Các OS khác — tính phí theo giờ
- Chi phí cao nhất, nhưng không cần trả trước
- Không cam kết dài hạn
- Khuyến nghị cho workload ngắn hạn, không gián đoạn, mà bạn không đoán trước được ứng dụng sẽ hoạt động ra sao
- Pay for what you use:
- Linux or Windows - billing per second, after the first minute
- All other operating systems - billing per hour
- 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
18. EC2 Reserved Instances
- Giảm giá tới 72% so với On-Demand
- Bạn reserve các thuộc tính cụ thể của instance (Instance Type, Region, Tenancy, OS)
- Reservation Period — 1 năm (+ discount) hoặc 3 năm (+++ discount)
- Payment Options — No Upfront (+), Partial Upfront (++), All Upfront (+++)
- Scope của Reserved Instance — Regional hoặc Zonal (reserve capacity trong một AZ)
- Khuyến nghị cho ứng dụng có usage ổn định (steady-state), ví dụ database
- Có thể mua/bán trên Reserved Instance Marketplace
- Convertible Reserved Instance
- Có thể đổi instance type, instance family, OS, scope và tenancy
- Giảm giá tới 66%
Lưu ý: các % giảm giá có thể khác so với video vì AWS thay đổi theo thời gian — con số chính xác không cần thiết cho kỳ thi, chỉ mang tính minh hoạ.
- Up to 72% discount compared to On-demand
- You reserve a specific instance attributes (Instance Type, Region, Tenancy, OS)
- Reservation Period – 1 year (+discount) or 3 years (+++discount)
- Payment Options – No Upfront (+), Partial Upfront (++), All Upfront (+++)
- Reserved Instance's Scope – Regional or Zonal (reserve capacity in an AZ)
- Recommended for steady-state usage applications (think database)
- You can buy and sell in the Reserved Instance Marketplace
- Convertible Reserved Instance
- Can change the EC2 instance type, instance family, OS, scope and tenancy
- Up to 66% discount
Note: the % discounts are different from the video as AWS change them over time – the exact numbers are not needed for the exam. This is just for illustrative purposes.
19. EC2 Savings Plans
- Được giảm giá dựa trên usage dài hạn (tới 72% — giống Reserved Instances)
- Cam kết một mức usage nhất định (ví dụ $10/giờ trong 1 hoặc 3 năm)
- Usage vượt mức cam kết trong Savings Plan sẽ bị tính theo giá On-Demand
- Bị khoá theo một instance family & region cụ thể (ví dụ M5 tại
us-east-1) - Linh hoạt theo:
- Instance Size (ví dụ
m5.xlarge,m5.2xlarge) - OS (ví dụ Linux, Windows)
- Tenancy (Host, Dedicated, Default)
- Instance Size (ví dụ
- Get a discount based on long-term usage (up to 72% - same as RIs)
- 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 (e.g., M5 in us-east-1)
- Flexible across:
- Instance Size (e.g., m5.xlarge, m5.2xlarge)
- OS (e.g., Linux, Windows)
- Tenancy (Host, Dedicated, Default)
20. EC2 Spot Instances
- Có thể được giảm giá tới 90% so với On-Demand
- Là những instance bạn có thể "mất" bất cứ lúc nào nếu max price bạn đặt thấp hơn spot price hiện tại
- Là loại instance tiết kiệm chi phí nhất trong AWS
- Hữu ích cho workload có khả năng chịu lỗi (resilient to failure):
- Batch jobs
- Data analysis
- Image processing
- Bất kỳ distributed workload nào
- Workload có thời gian bắt đầu/kết thúc linh hoạt
- Không phù hợp cho job quan trọng hoặc database
- Can get a discount of 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
- The MOST cost-efficient instances in AWS
- 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
21. EC2 Dedicated Hosts
- Một physical server có toàn bộ capacity EC2 instance dành riêng cho bạn
- Giúp đáp ứng yêu cầu compliance và tận dụng license phần mềm ràng buộc theo server sẵn có (per-socket, per-core, per-VM software license)
- Tuỳ chọn mua:
- On-Demand — trả theo giây khi Dedicated Host đang active
- Reserved — 1 hoặc 3 năm (No Upfront, Partial Upfront, All Upfront)
- Là tuỳ chọn đắt nhất
- Hữu ích cho phần mềm có mô hình license phức tạp (BYOL — Bring Your Own License)
- Hoặc cho công ty có yêu cầu quy định/compliance nghiêm ngặt
- A physical server with EC2 instance capacity fully dedicated to your use
- Allows you 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)
- 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 needs
22. EC2 Dedicated Instances
- Instance chạy trên hardware dành riêng cho bạn
- Có thể dùng chung hardware với instance khác trong cùng account
- Không kiểm soát được vị trí đặt instance (hardware có thể đổi sau khi Stop / Start)
- 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)
23. EC2 Capacity Reservations
- Đặt trước capacity của On-Demand instance ở một AZ cụ thể, trong khoảng thời gian bất kỳ
- Luôn đảm bảo có capacity EC2 sẵn sàng khi bạn cần
- Không cam kết thời gian (tạo/huỷ bất cứ lúc nào), không có discount về billing
- Có thể kết hợp với Regional Reserved Instances và Savings Plans để vẫn hưởng discount
- Bạn bị tính phí theo giá On-Demand dù có chạy instance hay không
- Phù hợp cho workload ngắn hạn, không gián đoạn, cần nằm ở một AZ cụ thể
- 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
24. Nên chọn tuỳ chọn mua nào? (Which Purchasing Option Is Right for Me?)
Ví dụ minh hoạ bằng việc thuê phòng khách sạn/resort:
- On-Demand: đến và ở lại resort bất cứ khi nào ta muốn, trả full giá
- Reserved: giống như lên kế hoạch trước — nếu định ở lâu dài, ta có thể được giảm giá tốt
- Savings Plans: trả một mức cố định mỗi giờ trong một khoảng thời gian, và có thể ở bất kỳ loại phòng nào (King, Suite, Sea View...)
- Spot Instances: khách sạn cho phép mọi người đấu giá các phòng trống, ai trả cao nhất giữ phòng — bạn có thể bị "đuổi" bất cứ lúc nào
- Dedicated Hosts: ta thuê nguyên một toà nhà của resort
- Dedicated Instances: bạn được ở một phòng riêng không khách nào khác dùng chung — nhưng khách sạn tự quyết xếp phòng nào, và lần nhận phòng sau có thể đổi sang phòng khác (khác với Dedicated Hosts là thuê nguyên toà nhà)
- Capacity Reservations: bạn đặt một phòng trong một khoảng thời gian với giá đầy đủ, kể cả khi không ở
Illustrated with a hotel/resort analogy:
- 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
- Dedicated Instances: you get a private room that no other guests share — but the hotel decides which room, and it may move you to a different one on your next check-in (unlike Dedicated Hosts where you book the whole building)
- Capacity Reservations: you book a room for a period with full price even you don't stay in it
25. So sánh giá (Price Comparison)
Ví dụ — m4.large – us-east-1:
Example – m4.large – us-east-1:
| Price Type | Price (per hour) |
|---|---|
| On-Demand | $0.10 |
| Spot Instance (Spot Price) | $0.038 - $0.039 (up to 61% off) |
| Reserved Instance (1 year) | $0.062 (No Upfront) - $0.058 (All Upfront) |
| Reserved Instance (3 years) | $0.043 (No Upfront) - $0.037 (All Upfront) |
| EC2 Savings Plan (1 year) | $0.062 (No Upfront) - $0.058 (All Upfront) |
| Reserved Convertible Instance (1 year) | $0.071 (No Upfront) - $0.066 (All Upfront) |
| Dedicated Host | On-Demand Price |
| Dedicated Host Reservation | Up to 70% off |
| Capacity Reservations | On-Demand Price |
26. EC2 Spot Instance Requests
- Có thể được giảm giá tới 90% so với On-Demand
- Định nghĩa max spot price, và nhận được instance khi spot price hiện tại < max price
- Spot price theo giờ thay đổi dựa trên offer và capacity
- Nếu spot price hiện tại > max price của bạn, bạn có thể chọn stop hoặc terminate instance, với grace period 2 phút
- Dùng cho batch job, data analysis, hoặc workload chịu được lỗi
- Không phù hợp cho job quan trọng hoặc database
- Can get a discount of up to 90% compared to On-demand
- Define max spot price 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 minutes grace period
- Used for batch jobs, data analysis, or workloads that are resilient to failures
- Not great for critical jobs or databases
27. Cách huỷ Spot Instances (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.
- Chỉ có thể cancel Spot Instance request đang ở trạng thái open, active, hoặc disabled
- Huỷ Spot Request không tự động terminate instance
- Bạn phải cancel Spot Request trước, sau đó mới terminate Spot Instance liên quan
- 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
28. Spot Fleets
- Spot Fleet = tập hợp các Spot Instance + (tuỳ chọn) On-Demand Instance
- Spot Fleet sẽ cố gắng đáp ứng target capacity trong giới hạn về giá
- Định nghĩa các launch pool khả dĩ: instance type (ví dụ
m5.large), OS, Availability Zone - Có thể có nhiều launch pool, để fleet có thể lựa chọn
- Spot Fleet dừng launch instance mới khi đạt capacity hoặc đạt max cost
- Các chiến lược phân bổ Spot Instance:
- lowestPrice: lấy từ pool có giá thấp nhất (tối ưu chi phí, workload ngắn)
- diversified: phân tán trên tất cả pool (tốt cho availability, workload dài)
- capacityOptimized: chọn pool có capacity tối ưu cho số lượng instance cần
- priceCapacityOptimized (khuyến nghị): chọn pool có capacity cao nhất, sau đó chọn pool có giá thấp nhất (lựa chọn tốt nhất cho đa số workload)
- Spot Fleet cho phép ta tự động request Spot Instance với giá thấp nhất
- 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
- priceCapacityOptimized (recommended): pools with highest capacity available, then select the pool with the lowest price (best choice for most workloads)
- Spot Fleets allow us to automatically request Spot Instances with the lowest price