Labs ICT
⭐ Pro Login

EC2 and Auto Scaling

Managing virtual machines with Elastic Compute Cloud

EC2 and Auto Scaling

Amazon EC2 (Elastic Compute Cloud) provides scalable virtual servers in the AWS cloud. Combined with Auto Scaling, EC2 ensures you have the right amount of compute power at the right time.

EC2 Instance Types


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Instance Type  β”‚  Best For                     β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚  t3, t3a        β”‚  Burstable: dev, test, small  β”‚
  β”‚                 β”‚  web apps                      β”‚
  β”‚  m5, m6i        β”‚  General: balanced compute    β”‚
  β”‚                 β”‚  and memory                    β”‚
  β”‚  c5, c6i        β”‚  Compute: CPU-intensive tasks  β”‚
  β”‚                 β”‚  like batch processing         β”‚
  β”‚  r5, r6i        β”‚  Memory: in-memory databases, β”‚
  β”‚                 β”‚  real-time analytics           β”‚
  β”‚  g4, g5         β”‚  GPU: machine learning, video β”‚
  β”‚                 β”‚  rendering, gaming             β”‚
  β”‚  i3             β”‚  Storage: high I/O workloads   β”‚
  β”‚                 β”‚  like NoSQL databases          β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

EC2 Lifecycle


  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  start  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  running  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚Stopped │────────▢│Pending │──────────▢│ Runningβ”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
                                    stop/rebootβ”‚terminate
                                         β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
                                         β”‚Stopped/  β”‚
                                         β”‚Terminatedβ”‚
                                         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key states: Stopped (not running, you still pay for storage), Running (actively running, you pay per hour/second), Terminated (deleted, storage is freed).

Auto Scaling Groups (ASG)

ASGs automatically adjust the number of EC2 instances based on demand. You define minimum, maximum, and desired capacity. CloudWatch alarms trigger scaling actions.


  Traffic Spikes:              Auto Scaling Response:
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ High     β”‚  CloudWatch     β”‚  Scale UP β”‚
  β”‚ CPU (80%)β”‚  Alarm Triggers β”‚  +2 EC2   β”‚
  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜                 β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
       β”‚                            β”‚
       β–Ό                            β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Low      β”‚  CloudWatch     β”‚Scale DOWN β”‚
  β”‚ CPU (20%)β”‚  Alarm Triggers β”‚  -1 EC2   β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Cost Tips

Use Spot Instances for fault-tolerant workloads β€” save up to 90%. Use Reserved Instances or Savings Plans for predictable workloads β€” save up to 72%. Use On-Demand for unpredictable, short-term needs. Always set up billing alerts to avoid surprises.

πŸ§ͺ Quick Quiz

What does EC2 stand for?