Labs ICT
⭐ Pro Login

Auto Scaling and Elasticity

Automatically adjusting resources to match demand

Auto Scaling and Elasticity

Elasticity is the ability to scale resources up or down dynamically based on demand. Combined with auto scaling, it ensures your applications have the right amount of resources at all times β€” no more, no less.

Auto Scaling Flow


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚            AUTO SCALING WORKFLOW                      β”‚
  β”‚                                                      β”‚
  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
  β”‚  β”‚ CloudWatch│───▢│  Scaling │───▢│  Launch/ β”‚      β”‚
  β”‚  β”‚  Alarm    β”‚    β”‚  Policy  β”‚    β”‚ Terminateβ”‚      β”‚
  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚  Instanceβ”‚      β”‚
  β”‚       β–²                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
  β”‚       β”‚                                 β”‚           β”‚
  β”‚       β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚           β”‚
  β”‚       └─────────│  Metrics β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
  β”‚                 β”‚  (CPU,   β”‚                        β”‚
  β”‚                 β”‚  memory, β”‚  New instances join    β”‚
  β”‚                 β”‚  requestsβ”‚  the load balancer     β”‚
  β”‚                 β”‚  etc.)   β”‚                        β”‚
  β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Scaling Policies

Target Tracking: Maintain a target metric (e.g., keep CPU at 50%). AWS adjusts capacity automatically.

Step Scaling: Scale based on CloudWatch alarms with step adjustments (e.g., add 2 instances at 60% CPU, add 4 at 80%).

Simple Scaling: Add or remove a fixed number of instances based on a single alarm. Least recommended.

Scaling Strategies


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Strategy        β”‚  When to Use                     β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  Reactive        β”‚  Scale after demand increases    β”‚
  β”‚                  β”‚  (catch up with traffic)          β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  Scheduled       β”‚  Predictable traffic patterns    β”‚
  β”‚                  β”‚  (e.g., scale up at 9am)         β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  Predictive      β”‚  ML-based forecasting            β”‚
  β”‚                  β”‚  (AWS Auto Scaling)              β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  Step            β”‚  Fine-grained multi-step scaling β”‚
  β”‚                  β”‚  (complex scaling needs)         β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Best Practices

Set appropriate minimum and maximum instance counts. Use warm-up periods to avoid thrashing. Design applications to handle being started and stopped. Use lifecycle hooks for graceful shutdown. Combine with load balancers for seamless scaling. Test scaling behavior under load.

πŸ§ͺ Quick Quiz

What is auto scaling?