AWS
DevOps
  • knowledge
    • glossary
    • network knowledge
      • CIDR Block
      • OSI
      • List of Ports
      • Network model
    • AWS best practices
      • Least privilege principle
      • Support Plan
      • Well-architected framework
        • Well-architected framework
        • Cost optimization
        • Operational Excellence
        • Performance efficiency
        • Reliability
        • Security
    • Exams
      • DOP-C02
        • DOP-C02 topics
        • DOP-C02 Labs
      • DVA-C02
      • SOA-C02
  • services
    • access management
      • Directory Service
      • IAM
        • PassRole
      • IAM Identity Center (SSO)
      • Organizations
        • Organizational Unit
        • Control Tower
      • AD Domain Service
    • analytics
      • data analytic
        • Athena
        • QuickSight
        • Redshift
      • data collection
        • Data Lake
        • Lake Formation
      • data processing
        • EMR
        • Kinesis
        • Glue
          • Glue Data Catalog
      • OpenSearch
    • compute
      • Batch
      • EC2
        • Auto Scaling
        • AMI
        • ELB
          • Global accelerator
        • Security Group
        • EBS
        • EC2 Instance Store
        • Spot Fleet
      • Elastic Beanstalk
      • Lambda
        • Layer
        • Lambda API
      • Outposts
      • Wavelength
      • SAM
      • VMWare Cloud
    • container
      • Copilot
      • ECR
      • ECS
        • ECS Anywhere
      • EKS
        • EKS Anywhere
        • EKS Distro
      • Fargate
    • cost management
      • Budgets
      • Cost Explorer
      • Saving Plans
      • Compute Optimizer
    • database
      • Data Engineer
      • Document DB
      • DynamoDB
        • DynamoDB API
        • Scan
      • ElastiCache
      • Keyspaces
      • MemoryDB for Redis
      • Neptune
      • Quantum Ledger Database
      • RDS
        • Aurora
          • Aurora Global Database
          • Aurora Serverless
      • Timestream
    • devTools
      • CICD
        • CodeArtifact
        • CodeCommit
        • CodeBuild
        • CodeDeploy
        • CodePipeline
      • CloudFormation
      • CodeGuru
      • CodeStar
      • CodeWhisperer
      • X-Ray
      • Deployment strategies
    • finance
      • Cost explorer
    • integration
      • AppFlow
      • AppSync
      • EventBridge
      • MQ
      • SNS
      • SQS
      • Step Functions
      • SWF
    • management
      • AppConfig
      • AWS Backup
      • AWS CDK
      • Config
      • Grafana
      • Health Dashboard
      • Proton
      • Service Catalog
      • System Manager
      • SSM
      • Resource Group
      • OpsWorks (discontinued)
    • media
      • Elemental MediaConvert
      • Transcoder
    • messaging
      • SES
    • migration
      • Application Migration Service
      • DataSync
      • DMS
      • Migration Evaluator
      • Migration Hub
      • Server Migration Service
      • Snow Family
      • Transfer Family
    • ML
      • Comprehend
      • Forecast
      • Kendra
      • Lex
      • Rekognition
      • SageMaker
        • SageMaker Data Wrangler
        • SageMaker ML Lineage Tracking
    • monitoring
      • CloudTrail
      • CloudWatch
      • TrustedAdvisor
    • networking
      • CloudFront
      • Customer gateway
      • Edge Location
      • hybrid networking
        • Direct Connect
          • Direct Connect Gateway
        • Site-to-site VPN
      • PrivateLink
      • Region
        • AZ
      • Route 53
      • Transit Gateway
      • VPC
        • VPC Lattice
        • Subnet
          • NACL
        • Internet Gateway
        • Network Firewall
        • VPN
        • NAT Gateway
      • Virtual Private Gateway
    • security
      • Artifact
      • ACM
      • CloudHSM
      • Cognito
      • Detective
      • Firewall Manager
      • GuardDuty
      • Inspector
      • KMS
      • Macie
      • Network Firewall
      • Resource Access Manager
      • Security Hub
      • Secret Manager
      • Secret Hub
      • Shield
      • STS
      • Trusted Advisor
      • WAF
    • storage
      • Backup
      • EBS
      • EFS
      • FSx
      • S3
        • S3 Glacier
        • S3 Snippet
        • S3 Mountpoint
      • Snow family
      • Storage gateway
      • WorkDocs
    • web & mobile
      • Amplify
      • API Gateway
      • Device Farm
      • Pinpoint
Powered by GitBook
On this page
  • Termination policy
  • Scaling policy
  • Simple scaling policy
  • Target tracking policy
  • Options
  • ELB Health check
  • Scale-in protection
  • Instance scale-in protection
  • Standby Instance
  • Lifecycle
  • Lifecycle Transition
  • Lifecycle hooks
  • Trivia
  1. services
  2. compute
  3. EC2

Auto Scaling

PreviousEC2NextAMI

Last updated 1 year ago

Termination policy

Scaling policy

Simple scaling policy

  • Simple & straight forward scaling policy, when a threshold meet -> adding or removing a specified number of instances.

Target tracking policy

  • Create it own Cloudwatch alarms.

  • There's no need for a cooldown period like in Simple Scaling Policies because the policy continuously tracks the metric and adjusts the capacity to maintain the target level.

  • Ex: Target value of CPU utilization is 50% -> it will create 2 alarms (1 for 50%, 1 for 35%). When the 35% reach, it will scale to maintain the CPU utilization at 50%.

Options

ELB Health check

Be careful with this option.

You need to add the instance to Target group first, before enable this option. If not your instance will automatically terminated if that do not have Scale-in protection turn on.

  • If will check all the instance (health check) in the Target group, if 1 instance fail the Health check -> replace that instance. If it keep replacing the instance, then something is wrong with the Health check.

  • If there are multiple Target group attached to the ASG, all the instance in each Target group need to be healthy.

Scale-in protection

Turn this on if you want to protect a specific instance. There is an Instance scale-in protection, so do not mistaken with that.

This will not protect the instance from manual operation.

When you stop the instance, the ASG will consider the instance is not healthy and replace it. It will terminate it even though you Enable the Terminate protection for that instance.

Instance scale-in protection

If protect from scale in is enabled, newly launched instances will be protected from scale in by default. This will protect the instance from the launch.

This will prevent the ASG from scale-in, so turn it ON only when you understand the down fall of this.

Standby Instance

  • This option will remove the instance from the management of ASG.

  • ASG will not check the health of standby instances until it return to InService

  • When a terminated instance is changed from StandBy to InService, it first checks the health of that instance

    • Healthy -> InService

    • Unhealthy -> remove & create a new instance from the Launch Template.

The ASG will not check the Health of Standby instances. So even you manually terminate the instance outside of ASG, the ASG will not know so the Standby instance is always healthy.

-> You need to check the EC2 instance information to determine healthy or not.

Lifecycle

Lifecycle Transition

When instances launch or terminate, they transition between different states.

  • Launch states: Pending => Pending:Wait => InService

  • Terminate states: InService => Terminating:Wait => Terminated

Lifecycle hooks

Lifecycle hooks in AWS Auto Scaling provide a powerful mechanism to execute custom actions on instances during launch or termination events.

Heartbeat timeout

  • The amount of time, in seconds, for the instances to remain in wait state.

  • Min: 30sec, max: 2H

Trivia

  • ASG scale between Min instance and Max instance. The number of instance depend on Desired instances.