Skip to content

Best practices with ASG

0

Hello, I've read somewhere that it's a best practice to have one ASG per AZ but I didn't find any official documentation about it.

Also, what are best pratices in term of ASG ? On what parameter can I regroup multiple ASG ? Actually, we have one ASG per AZ and "EC2 category" like ASG for xlarge, ASG for 2xlarge etc ..

Thanks

asked a year ago890 views
1 Answer
1

When managing Auto Scaling Groups (ASGs), several best practices can help optimize performance, reliability, and cost-efficiency. Let’s break down the key considerations:

Single vs. Multiple ASGs per AZ:

While the idea of having one ASG per Availability Zone (AZ) is sometimes employed for specific use cases, it’s not a universal AWS best practice. Generally, the preferred approach is to have a single ASG spanning multiple AZs, as this simplifies management and ensures that AWS distributes instances evenly across zones for better fault tolerance and availability. However, in certain scenarios—like when you need to isolate failure domains or if there are performance requirements tied to specific AZs—you may opt for one ASG per AZ.

For general workloads, using a single ASG across multiple AZs is sufficient and helps in automatic distribution of traffic and fault isolation without the need to manage multiple ASGs manually.

Best Practices for ASGs:

  1. Distribute Instances Across Multiple AZs:
    It is best to use a single ASG spread across multiple AZs for fault tolerance. AWS can distribute instances evenly across AZs, ensuring better resilience to zone-specific outages.

  2. Leverage Target Tracking Scaling Policies:
    Scaling based on metrics like CPU utilization, memory usage, or custom metrics helps dynamically adjust your application’s capacity in response to demand, avoiding under or over-provisioning of resources. AWS Auto Scaling also supports predictive scaling to anticipate demand based on historical data.

  3. Implement Comprehensive Health Checks:
    Enable both EC2 and ELB health checks to ensure that any unhealthy instances are automatically terminated and replaced, ensuring the ongoing health and reliability of your infrastructure.

  4. Use Launch Templates for Flexibility:
    Always favor using launch templates over launch configurations. Launch templates provide greater flexibility by supporting multiple versions and parameters, allowing you to use different instance types and spot instances within the same ASG.

  5. Cost Optimization with Mixed Instance Types:
    Optimize costs by using a combination of On-Demand and Spot instances. You can allocate instance weights within the ASG to manage the proportion of each type of instance. This helps reduce costs while maintaining performance.

  6. Scaling Across Workloads:
    For complex environments, using multiple ASGs to group instances by instance type (e.g., separating xlarge from 2xlarge instances) or by application type (e.g., compute-optimized vs. memory-optimized) can allow you to fine-tune the scaling behaviors of different workloads.

Grouping ASGs:

  • By Instance Types (as you're currently doing): Grouping ASGs by instance size (e.g., xlarge vs. 2xlarge) can make sense when specific workloads benefit from different instance classes. This allows for more granular control over scaling policies and cost optimizations based on the needs of the application.

  • By Application or Microservice: Splitting ASGs based on application or service allows you to scale each one independently. For instance, compute-heavy tasks may require different scaling thresholds than memory-heavy tasks.

  • Spot and On-Demand Instances: You can optimize costs by mixing Spot and On-Demand instances in ASGs. AWS enables the use of weighted capacities to manage this mix efficiently.

For more in-depth insights, I recommend reviewing AWS's blog on preparing applications for scalable infrastructure and the best practices outlined for AWS Auto Scaling in these references:

These resources provide additional context on setting up and optimizing your scaling strategies.

answered a year ago
EXPERT
reviewed a year ago
AWS
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.