CS/클라우드컴퓨팅

Lec 04-3: Managing Amazon EC2

호프 2023. 10. 15. 19:10

Lanching options

  • AWS Management Console
  • AWS Command Line Interface (CLI)
  • AWS Software Development Kit (SDK)
  • Other AWS services: AWS CloudFormation, AWS OpsWorks, AWS Elastic Beanstalk

Amazon EC2 Lifecycle States

Pending - Not billed

  • preparing to enter the running state
  • when it launching for the first time or when it starting after being in the stopped state.

Running - Billed

  • running and ready for use

Rebooting - Billed

  • rebooting its operating system

Shuttle-down - Not billed

  • preparing to be terminated

Terminated - Not billed

  • permanently deleted and cannot be started

Stopping - Not billed if preparing to stop. Billed if preparing to hibernate

  • preparing to be stopped or stop-hibernated

Stopped - Not billed

  • shut down and cannot be used. can be started at any time

Stop-hibernated - Not biled

  • shut down and cannot be used. can be started at any time.
Stopped, Stop-hibernated, Stopping -> Only instances backed by Amazon EBS

Scaling options

Vertical Scaling

  • upgrading or downgrading server capacity of an EC2 instance
  • 3 Steps
    1. Stop the instance
    2. Make the desired change to the instance size or type
    3. Start the instance
  • Disadvantages of Vertical scaling
    • Manual process
    • Challenging when you have multiple instances to manage
    • Limitd on the instance scalability
    • Requires the instance to be unavailable while making changes

Use Case

  • The instance size is too weak to process basic workload tasks
  • Horizontal Scaling would not work in this scenario, because adding more instances would not address the issue of instances that cannot handle basic processing needs.

Horizontal Scaling

  • adding or removing Amazon EC2 instances
  • It can be automated by using the Amazon EC2 Auto Scaling service
  • Can add as many instances as you need and terminate them when they are no longer needed.
  • Benefits
    • Improves fault tolerance
    • Increases application availability
    • Lowers costs
    • Requires no downtime to implement

Use Case

  • More requests are coming in than your instance can keep up with
  • Vertical scaling would not be the best option because your application would need to be offline while you scaled up and down.

Auto Scaling

  • Amazon EC2 Auto Scaling can help you automate horizontal scaling according to conditions that you define
  • Can launch instances across Availability Zones
  • Replaces instances
  • Helps to save money

Amazon EC2 Auto Scaling Options

  • Scheduled scaling
    • known load changes based on a schedule
  • Dynamic Scaling
    • follow the demand curve, which reduces the need to manually provision EC2 capacity in advance
    • Can use target tracking scaling policies to select a metric such as CPU utilization
  • Predictive scaling
    • Use machine learning to schedule
    • removes the need for manual adjustment to EC2 Auto Scaling parameters

Traffic management

Elastic Load Balancing (ELB)

  • ELB is scalable AWS service that automatically distributes incoming application traffic accross multiple EC2 target.

ELB Options

  • Application Load Balancer
    • ideal for load balancing HTTP and HTTPS traffic.
    • operates at the request level(layer 7)
  • Network Load Balancer
    • ideal for load balancing TCP and UDP traffic
    • when you need ultra-high performance and static IP addresses for your application
    • operates at the connection level (layer 4)
  • Gateway Load Balancer
    • helps you to manage your third-party virtual appliances
    • operates at the network level (layer 3) and provides a gateway for distributing traffic accross multiple virtual appliances

Additional Options for Connecting to EC2

  • EC2 Instance Connect
    • using SSH
    • connect with a valid username without a key pair
  • Session Manager
    • fully-managed AWS Systems Manager capability
    • manage instance through an interactive one-click, browser-based shell or through the AWS CLI
  • SSH Client
    • connect with a key pair
  • EC2 serial console
    • provides access to your intance's serial port
    • you can enter commands to an instances

Cost optimization

  • Using the right size instance
  • Increasing elasticity
    • reducing the amount of server capacity that is idle by implementing deployments that are elastic
    • Automatic scaling
  • Choosing optimal pricing models
  • Optimizing storage choices