Module 2: Compute in the Cloud --- part 1
學習目標
- Amazon EC2 簡介 & 優點
- Amazon EC2 Instance Types
- Amazon EC2 Pricing(各種計費選項)
- Amazon EC2 Auto Scaling 優點
- Elastic Load Balancing 優點 & 使用範例
- Amazon Simple Notification Service (Amazon SNS) vs. Amazon Simple Queue Service (Amazon SQS)
- 其他 AWS compute options
Amazon EC2 簡介
Amazon Elastic Compute Cloud (Amazon EC2) provides secure, resizable compute capacity in the cloud as Amazon EC2 instances.
Amazon EC2 優點
Using EC2 for compute is highly flexible, cost effective, and quick when you compare it to running your own servers on premises in a data center that you own.
Multitenancy 多租戶(技術)
Sharing underlying hardware (sharing the host) between virtual machines (multiple other instances).
「多租戶技術」是一種軟體架構技術,它是在探討與實作如何於多使用者的環境下共享相同的系統或程式元件,並且仍可確保各使用者間資料的隔離性。
Hypervisor
- A hypervisor running on the host machine is responsible for coordinating the "Multitenancy".
- The hypervisor is responsible for isolating the virtual machines from each other as they share resources from the host.
EC2 Instance
使用 EC2,你只需要對 running instances 付費 (pay only for the compute time you use),而 stopped instances 或 terminated instances 則無需付費。
- EC2 instances are secure and separate from each other.
- EC2 instances are resizable. (give more memory or CPU, Vertical Scaling)
- Control the networking aspect of EC2, such as
- what type of requests make it to your server
- if they are publicly or privately accessible is something you decide
- Compute as a service (CaaS) Model
How Amazon EC2 works
Step 1: Launch
首先,為你的 instance 選擇具有基本配置(包括作業系統、application server 或 applications)的模板,亦可選擇擁有特殊硬體配置的 instance type。
Amazon EC2 configurations:
- Windows
- Linux
- Internal business apps
- Web apps
- Databases
- Third-party software
Amazon EC2 Instance Types
Each Amazon EC2 instance type is grouped under an instance family and are optimized for certain types of tasks.
Amazon EC2 instance families
(1) General purpose instances
- Balanced resources
- Diverse workloads
- e.g. web servers, code repositories
(2) Compute optimized instances
- Compute intensive tasks
- Offer high-performance processors
- e.g. gaming servers, high-performance computing (HPC), scientific modeling, batch processing workloads
(3) Memory optimized instances
- Memory intensive tasks
- e.g. high-performance database, a workload that involves performing real-time processing of a large amount of unstructured data
補充:
在運算中,記憶體(memory)是一個暫存區,用來儲存中央處理單元(CPU)完成操作所需的資料和指令。在電腦程式或應用程式運行之前,必須先從 storage 載入至 memory。這個預載過程使 CPU 能夠直接存取程式。
(4) Accelerated computing instances
- Utilize hardware accelerators, or coprocessors
- e.g. floating-point number calculations, graphics processing, data pattern matching, game/application streaming
(5) Storage optimized
- High performance for locally stored data (faster large datasets access)
- e.g. distributed file systems, data warehousing applications, and high-frequency online transaction processing (OLTP) systems
- IOPS:每秒輸入/輸出操作數 (IOPS, input/output operations per second)
- 衡量儲存設備效能的指標,是 storage device 讀寫速度的衡量標準
- Input operation ➡ data put into a system (e.g. 資料儲存到 DB)
- Output operation ➡ data generated by a server (e.g. 產出的分析結果)
- IOPS indicates how many different input or output operations a device can perform in one second.
Amazon EC2 Pricing
(1) On-Demand
- 使用時機:
- 無法中斷的短期、不規律工作負載(irregular workloads, running applications that have unpredictable usage patterns)
- e.g. 開發和測試應用程式、get a baseline for your average usage
- 對於持續一年或更長時間的工作負載,不建議使用 On-Demand,因為使用 Reserved Instances 可以更省錢。
- 跑/開多久,付多少(不同 instance type 價格不同)
- 不需提前付款
- 不需綁合約
(2) Savings Plans
- 使用時機:
- 長期(超過一年)且靈活地使用 EC2
- 選擇 Region 和 EC2 instance family 來跑 EC2 instance (e.g. M5 usage in N. Virginia)
- 比 Reserved Instances 更靈活
- 不需要預先指定 instance type and size, OS 和 tenancy
- 沒有 EC2 capacity reservation
- 更便宜價格(savings of up to 72%)
- 未達合約簽訂的 usage,以 Savings Plans 折扣費率計算 ($10 per hour)
- 超過 usage,則按 On-Demand 費率計算
- 簽訂一年或三年的長期合約
- 此種定價模式,有對 Amazon EC2、AWS Lambda 和 AWS Fargate 用量提供低廉的價格
(3) Reserved Instances
- 使用時機:
- 無法中斷的長期(超過一年)、規律工作負載 steady-state workloads
- 更便宜價格(savings of up to 75%)
- 簽訂一年或三年的長期合約
- 當 Reserved Instances 合約到期時,EC2 instances 仍可持續運行、不中斷,但會改用 On-Demand 費率計價。
兩種 Reserved Instances 類型:
- Standard Reserved Instances
- 當你需求非常明確且是 steady-state applications 時,使用這個!
- Instance family/type and size (e.g. m5.xlarge)
- Platform description (e.g. OS: Red Hat Enterprise Linux)
- Tenancy: Default tenancy or dedicated tenancy
- Region
- EC2 capacity reservation:預留 N 個 EC2 instances 在特定 Availability Zone
- Convertible Reserved Instances
- 當你需要跑在不同 Availability Zone 上或使用不同 instance type 時,使用這個!
- 當你需要靈活地執行 EC2 instances 時,可享受更大的折扣。
(4) Spot Instances
- 使用時機:
- 具有靈活起始和結束時間的工作負載
- 你的 workload 必須是可以忍受中斷(如:batch workloads, data processing job)
- 使用閒置的 Amazon EC2,提供更更更便宜價格(savings of up to 90%)
- AWS 需要 EC2 時,可以隨時收回(兩分鐘警告並收回)
(5) Dedicated Hosts
- 使用時機:
- Certain compliance requirements
- 價格最貴!
- Nobody will share tenancy of that host.
- 實體伺服器,僅你專用
- 兩種選項
- On-Demand Dedicated Hosts(按需專用主機)
- Dedicated Hosts Reservations(預定專用主機)
留言
張貼留言