aws

EC2

ayleeee 2024. 3. 24. 12:00

EC2 인스턴스

  • Elastic Compute Cloud
  • AWS에서 제공하는 서버 
  • 가상화 환경에서 생성되는 서버. 다양한 운영체제 지원.
  • EC2 내부에 있는 저장소는 휘발성 저장소. 종료시 데이터 손실. 이를 방지 하기 위해서는 파일 스토리지 서비스를 이용해야 함

EC2 sizing & configuration options

  • OS
  • CPU
  • RAM
  • storage space
    • EBS & EFS (network-attached)
    • EC2 Instance store (hardware)
  • Network card : speed of the card, public ip address
  • Firewall rules : security group
  • Bootstrap script : EC2 User Data
    • 인스턴스가 최초로 시작될 때 EC2 User Data script를 실행. ( 최초 시작시, 단 한 번)
      • 예시) installing updates, installing software ...
    • root user 권한으로 작동.

EC2 Instance Types

  • e.g., m5.2xlarge
    • m : instance class
    • 5 : generation
    • 2xlarge : size within the instance class
  • General Purpose
    • web servers or code repositories
    • Balance between : 
      • Compute
      • Memory
      • Networking
  • Compute Optimized
    • compute-intensive tasks that require high performance processors
      • Batch processing workloads
      • Media transcoding
      • High performance web servers
      • Hight performance computing
      • Scientific modeling & machine learning
      • Dedicated gaming servers
  • Memory Optimized
    • Fast performance for workloads that process large data sets in memory
      • High performance, realational/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
  • Storage Optimized
    • Great for storage-intensive tasks that require high, sequential read and write access to large data sets on local storage
      • High frequency online transaction processing systems
      • Relational & NoSQL databases
      • Cache for in-memory databases
      • Data warehousing applications
      • Distributed file systems

Security Groups

  • fundamental of network security in AWS
  • control how traffic is allowed into or out of EC2 Instances
  • only contain allow rules
    • reference by IP or by security group
  • act as a "firewall"
    • regulate (1) Access to Ports (2) Authorized IP ranges (3) inbound network (4) outbound network
    • All inbound traffic is blocked by default
    • All outbound traffic is allowed by default
  • can be attached to multiple instances
  • locked down to a region/vpc combination
  • good to maintain one seperate security group for SSH access
  • not accessible -> security group issue
  • connection refused -> application error or not launched

Classic Ports 

  • 22 SSH log into a Linux instance
  • 21 FTP (File Transport Protocol) upload files into a file share
  • 22 SFTP (Secure File Transport Protocol) upload files using SSH
  • 80 HTTP
  • 443 HTTPS
  • 3389 RDP (Remote Desktop Protocol) log into a Window instance

EC2 Instances Purchasing Options

  • On-Demand Instances 
    • short workload, un-interrupted workloads, predictable pricing
    • Linux/Windows - billing per second, after the first minute
    • All ohter operating systems - billing per hour
  • Reserved ( 1 & 3 yrs)
    • Up to 72% discount compared to On-demand
    • Reserve a specific instance attributes
      • Instance type
      • Region
      • Tenancy
      • OS
    • Reserved Instances - long workloads
    • Convertible Reserved Instances - long workloads with flexible instances
    • Payment Options - No Upfront, Partial Upfront, All Upfront
    • Reserved Instance's Scope
      • Regional
      • Zonal
    • Recommend for steady-state usage applications, database
    • can buy and sell in the reserved instance marketplace
  • Savings Plan (1&3 yrs)
    • commitment to an amount of usage, long workload
    • get a discount based on long-term usage (up to 72%)
    • usage beyond EC2 Savings Plans is billed at the On-Demand price
    • locked to a specific instance family & AWS region
    • flexible across:
      • instance size
      • os
      • tenancy 
  • Spot Instances
    • short workloads, cheap, can lose instances (less reliable)
    • can get a discount of up to 90% compared to on-demand
    • MOST cost-efficient instances
    • workloads that are resilient to failure
      • batch jobs
      • data analysis
      • image processing
      • any distributed workloads
      • workloads with a flexible start and end time
  • Dedicated Hosts
    • book an entire physical server, control instance placement
    • allows you address compliance requirements and use existing server-bound software licenses
    • purchasing options
      • on-demand
      • reserved
    • the most expensive option
    • useful for software that have complicated licensing model or for companies that have strong regulatory or compliance needs
  • Dedicated Instances
    • instances run on hardware that's dedicated to you
    • no other customers will share the hardware
      • but, can share in same account
  • Capacity Reservations
    • reserve On-Demand instances capacity in a specific AZ for any duration
    • no time commitment (create/cancel anytime), no billing discounts
    • combine with regional reserved instances & saving plans to benefit from biling discounts
    • good for short-term, un interrupted workloads that needs to be in a specific AZ

EC2 Spot Instance Requests

  • Get a discount of up to 90% compared to On-demand
  • define max spot price
  • recommended for
    • bacth jobs
    • data analysis
    • workloads that are resilient to failures

Spot Fleets

  • Spot Fleets = set of Spot Instances + On-Demand Instances
  • The Spot Fleet will tryt to meet the target capacity with price constraints
  • Strategies to allocate Spot Instances
    • lowestPrice
    • diversified
    • capacityOptimized
    • priceCapacityOptimized

'aws' 카테고리의 다른 글

Elastic Beanstalk  (0) 2024.03.28
RDS  (1) 2024.03.27
High Availability & Scalability  (1) 2024.03.25
EC2 Instance Storage  (0) 2024.03.24
EC2 Associate  (0) 2024.03.24