Module 2: Compute in the Cloud --- part 2

學習目標

  • 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

Scalability & Elasticity

Scalability(可擴展性)involves beginning with only the resources you need and designing your architecture to automatically respond to changing demand by scaling out or in.


Amazon EC2 Auto Scaling

  • 功能
    • 用於自動水平擴展(新增、刪除) EC2 instances
  • 適用情境
    • 如果您嘗試造訪無法載入且經常逾時的網站,則該網站可能收到的請求數量超出了其處理能力。
  • 優點
    • 提高應用程式的可用性(availability)
  • Amazon EC2 Auto Scaling 兩種方法
    • Dynamic scaling:因應即時流量,增減 EC2 instances 數量
    • Predictive scaling:預測未來流量,並提前佈建適當的 EC2 instances 數量

To scale faster, you can use dynamic scaling and predictive scaling together.


Scale up vs Scale out

  • Scale up:垂直擴充,如:單個 EC2 instances 變更強大。
  • Scale out:水平擴充,如:EC2 instances 數量變多。

Auto Scaling group

  • 設定 Auto Scaling group
    • Desired capacity:Auto Scaling group 初始建立時的 instances 數量
    • Minimum capacity:擴充策略,Auto Scaling group 的最小 instances 數量
    • Maximum capacity:擴充策略,Auto Scaling group 的最大 instances 數量
  • 如果沒有設定 desired capacity,則預設為 minimum capacity 所設定的數量。


Directing Traffic with Elastic Load Balancing

A load balancer is an application that takes in requests and routes them to the instances to be processed.
  • Properly distribute traffic
    • High performance
    • Cost-efficient
    • Highly available
    • Automatically scalable

ELB (Elastic Load Balancing)

Elastic Load Balancing is the AWS service that automatically distributes incoming application traffic across multiple resources, such as Amazon EC2 instances. 

Ensuring that no single Amazon EC2 instance has to carry the full workload on its own.



ELB is a Regional construct. 

Because it runs at the Region level rather than on individual EC2 instances, the service is automatically highly available with no additional effort on your part. 


Messaging and Queuing

  • Tightly coupled architecture
    • Applications communicate directly. 
    • If a single component fails or changes, it causes issues for other components or even the whole system.
  • Loosely coupled architecture
    • Single failure won't cause cascading failures
    • 更可靠(reliable)的架構 ➡ Amazon SQS or Amazon SNS

Amazon SQS(Amazon Simple Queue Service)

  • 功能
    • SQS allows you to send, store, and receive messages between software components at any volume. (without losing messages or requiring other services to be available)
    • In Amazon SQS, an application sends messages into a queue. A user or service retrieves a message from the queue, processes it, and then deletes it from the queue.
  • 補充說明
    • Message queuing service
      • e.g. Order Board = SQS Queue
    • Payload: Data contained within a message
    • Amazon SQS queues: Where messages are placed until they are processed


    Amazon SNS(Amazon Simple Notification Service)

    • 功能
      • SNS is similar in that it is used to send out messages to services, but it can also send out notifications to end users.
    • 使用情境
      • 你可以發送一個訊息到 Amazon SNS topic,然後該訊息將一口氣(透過 mobile push、HTTP requests、SMS 或 email)分發給所有訂閱者
      • 訂閱者(Subscribers)可以是 SQS queues、AWS Lambda functions、web servers、email、HTTPS 或 HTTP web hooks ...
    • 補充說明
      • Publish/Subscribe model (Pub/Sub model)
        • A publisher publishes messages to subscribers
      • Amazon SNS topic: A channel for messages to be delivered


    Monolithic applications and microservices

    Monolithic application ➡ Tightly coupled components

    In this approach to application architecture, if a single component fails, other components fail, and possibly the entire application fails.


    To help maintain application availability when a single component fails, you can design your application through a microservices(微服務)approach.

    Microservices ➡ Loosely coupled components

    Two services facilitate application integration: 
    1. Amazon Simple Notification Service (Amazon SNS)
    2. Amazon Simple Queue Service (Amazon SQS)

    Additional Compute Services

    • Amazon EC2
      • 優點
        • Flexible
        • Reliable
        • Scalable
      • 使用情境
        • Host traditional applications
        • Full access to the OS

    Serverless


    “Serverless” means that your code runs on servers, but you do not need to provision or manage these servers. 
    (You cannot see or access the underlying infrastructure)


    Serverless Compute Options: AWS Lambda

    AWS Lambda is a service that lets you run code without needing to provision or manage servers. This allows you to just upload your code, and configure it to run based on triggers.

    • 適合 quick processing(Run time < 15 mins),如:web backend、handling requests
    • 使用情境
      • Host short running functions
      • Service-oriented applications
      • Event driven applications
      • No provisioning or managing servers


    Containerized

    Containers

    Containers provide you with a standard way to package your application's code and dependencies into a single object. (a package for your code)
    • 優點:Security, Reliability, Scalability



    Amazon ECS (Amazon Elastic Container Service)

    Amazon ECS is a highly scalable, high-performance container management system that enables you to run and scale containerized applications on AWS. 

    You can use ECS tools with EC2 instances.

    • 使用情境
      • Run Docker container-based workloads on AWS
      • Container orchestration tools
    • Supports Docker containers (Docker is a software platform that enables you to build, test, and deploy applications quickly.)

    Amazon EKS (Amazon Elastic Kubernetes Service)

    Amazon EKS is a fully managed service that you can use to run Kubernetes on AWS. 

    You can use EKS tools with EC2 instances.

    • 使用情境
      • Run container-based workloads on AWS
      • Container orchestration tools
    • Kubernetes is open-source software that enables you to deploy and manage containerized applications at scale.

    AWS Fargate

    AWS Fargate is a serverless compute engine for containers. It works with both Amazon ECS and Amazon EKS. 

    This allows you to run your containers on top of a serverless compute platform.

    • A serverless compute platform for ECS or EKS.
    • You do not need to provision or manage servers. AWS Fargate manages your server infrastructure for you.



    留言

    這個網誌中的熱門文章

    Module 2: Compute in the Cloud --- part 1

    考前加強:雲端重要概念