EC2 reliability is a combination of architecture (multi-instance, multi-AZ), automated recovery (Auto Scaling, Auto Recovery), and operational practices (AMIs, Image Builder, monitoring, and change management). Use the patterns in this article to reduce recovery time objectives (RTO) and increase overall availability.


If you can log in to the VM (EC2, EMR, RDS Custom), you are responsible for patching, securing, and monitoring the guest OS and any software you run. For managed services where you cannot log in (standard RDS, Lambda), AWS handles the underlying OS and host infrastructure.
Designing resilient EC2 deployments
Many resilient architectures combine EC2 with managed services such as Elastic Load Balancing and Auto Scaling. When focusing on EC2 itself, the core patterns are:- Run multiple instances (Auto Scaling across AZs) to avoid a single instance failure.
- Use Auto Recovery for impaired instances when supported (EBS-backed in a VPC) to keep the same instance ID and private IP.
- Prefer immutable infrastructure: build and bake AMIs, replace instances instead of patching them in-place.
- Use Fast Snapshot Restore for faster EBS boot and improved I/O performance from restored snapshots in specific Availability Zones.

- Auto Scaling groups (ASG) replace failed instances automatically. Even a single-instance ASG can keep a service available by launching a replacement.
- EC2 Auto Recovery attempts to recover impaired instances; when recovery works, instance IDs and private IPs remain unchanged.
- Enable EC2 Fast Snapshot Restore (FSR) for boot snapshots in AZs where you will restore frequently — this reduces boot and I/O latency compared with standard snapshot restores.
- Immutable infrastructure and baked AMIs: create tested AMIs and launch new instances rather than performing complex boot-time configuration.

Loose coupling and queues
Buffering and message-driven design decouple request arrival from processing, improving resilience:- Synchronous decoupling: load balancers and timeouts — a client waits for a response.
- Asynchronous decoupling: queues (SQS) and topics (SNS) — allow fire-and-forget or deferred processing.

- Upload → S3 generates a notification (SNS/S3 event) and sends a message to SQS.
- EC2 workers pull messages from SQS to process videos.
- Resiliency considerations:
- Make processing idempotent — record message IDs or processing markers in a database so retries don’t produce duplicate results.
- Use SQS visibility timeouts and dead-letter queues (DLQs) to avoid stuck or poison messages.
- Autoscale worker fleet based on queue depth with CloudWatch metrics.
- Use SNS to fan-out notifications to multiple SQS queues to support parallel processing or different consumers.

Image Builder, Launch Templates, and Auto Scaling refresh
- EC2 Image Builder automates AMI creation and testing as part of a repeatable pipeline.
- Integrate Image Builder with SNS/Lambda to automate launch template versioning and trigger Auto Scaling instance refreshes.
- Use Launch Templates with parameters and overrides to ensure consistent instance configurations across environments.

Consistent EC2 deployments across environments
Best practices for predictable deployments:- Use EC2 Launch Templates and parameterize differences (instance type, user data overrides).
- Automate AMI copying across accounts and regions as part of your release pipeline.
- Prefer baked AMIs for fast, predictable boot behavior; use instance user data for light bootstrap tasks only.

Monitoring and metrics
Metrics and logs are the foundation for detecting degradation and informing automated recovery:- Install and configure the CloudWatch agent on EC2 instances to collect OS-level and custom metrics.
- Stream logs to CloudWatch Logs; use CloudWatch Embedded Metric Format (EMF) to extract metrics from logs.
- Push application-specific metrics to CloudWatch via the PutMetricData API when necessary.
- Use the AWS CLI/SDK to pull metrics or integrate metric export into dashboards.

- Target tracking policies (for example, maintain average CPUUtilization near 40%) provide stable automated scaling behavior.
- Scheduled and predictive scaling are useful when you have consistent patterns and historical data (predictive scaling requires adequate historic metrics to forecast demand).
- CloudWatch alarms can trigger scaling policies for reactive scenarios.


- Use a target-tracking Auto Scaling policy bound to
CPUUtilizationor a custom metric to keep average utilization near the desired percentage. - Complement target tracking with scheduled scaling for predictable load spikes and predictive scaling when historical metrics provide reliable forecasts.

Change management and auditing
Control and visibility over changes reduce risk and help you detect configuration drift:
Instance types and reliability
- For most instance families, instance type does not materially affect basic reliability — requested vCPU and RAM are delivered as specified.
- Exception: T-family burstable instances use CPU credits and can throttle sustained CPU workloads — not suitable for consistent, CPU-bound services.
- For tenancy/isolation requirements, consider Dedicated Hosts (physical host allocation with placement visibility) or Dedicated Instances (instances on dedicated hardware).

Placement groups and instance placement
Placement groups influence availability and performance trade-offs:
Choose a placement strategy based on your availability and performance requirements.

EC2 Image Builder (again — pipelines and gold images)
- EC2 Image Builder is a managed service for producing standardized AMIs (golden images).
- It improves consistency and repeatability in your deployment pipeline; treat it as part of your CI/CD infrastructure rather than a runtime reliability control.

Elastic Beanstalk
Elastic Beanstalk is an orchestration layer that provisions AWS resources on your behalf and exposes configuration options (multi-AZ, load balancing, deployment strategies). Its reliability benefits come from the underlying AWS services (ELB, ASG, RDS, CloudWatch) it configures.
- Blue/green and immutable deployments minimize downtime by creating new capacity before switching traffic.
- Rolling and all-at-once deployments risk partial or full downtime during updates (all-at-once is highest risk).
- Choose deployment policies based on availability requirements and risk tolerance.


- Integrate application instrumentation (for example AWS X-Ray) to visualize service maps, latencies, and error traces across the stack and accelerate root-cause analysis.

Amazon Lightsail (honorable mention)
- Lightsail is a simple VPS-style service useful for small workloads and prototyping. It provides fewer low-level controls than EC2 and is typically out of scope for Solutions Architect Associate reliability questions.
- Use Lightsail for simplicity, EC2 for production workloads requiring fine-grained reliability and operational control.
