Study guide
Technical reference and lesson notes
Purpose of This Lesson
Amazon Elastic Compute Cloud (Amazon EC2) provides resizable virtual servers in AWS. EC2 is a foundational service because many AWS architectures use it directly, while other AWS services rely on similar compute concepts behind the scenes.
An EC2 design is more than simply launching a virtual machine. You must choose an operating system, instance configuration, storage, networking, security controls, and pricing model that match the workload’s requirements.
This lesson introduces the major EC2 decision areas that are developed in greater detail throughout an EC2-focused study section.
Key Concepts
EC2 instances are virtual servers
An EC2 instance is a virtual server running in an AWS Region and Availability Zone. Depending on the selected configuration, it can run operating systems such as:
- Linux
- Windows Server
- macOS, where supported by the relevant EC2 offering and Region
The instance type determines the underlying balance of compute resources, such as virtual CPUs, memory, networking capability, and sometimes specialized hardware.
An EC2 deployment has several independent decisions
Launching an instance requires more than selecting an instance type. Important choices include:
- Machine image: Select an Amazon Machine Image (AMI) containing the operating system and initial software configuration.
- Instance type: Choose the compute, memory, network, and accelerator characteristics.
- Storage: Attach the appropriate root and additional volumes, commonly using Amazon Elastic Block Store (EBS).
- Networking: Place the instance in a VPC subnet and determine how it communicates with other resources and the internet.
- IP addressing: Use private addressing for internal communication and public IPv4 or other supported addressing options when external reachability is required.
- Security: Apply security groups, IAM roles, patching, and host-level controls.
- Pricing model: Select an on-demand or commitment-based option, or use spare capacity where interruption is acceptable.
Separating these decisions helps avoid treating an EC2 instance as a single undifferentiated resource.
Storage is part of the architecture
An instance needs a root volume to boot its operating system. Applications may also require additional volumes for data, logs, databases, or temporary files.
Storage selection affects:
- Persistence when an instance is stopped or terminated
- Performance and latency
- Availability and recovery design
- Backup and restore procedures
- Cost
For example, application data that must survive replacement should not be treated as disposable instance-local data. The storage design must align with the application’s recovery requirements.
Networking determines reachability
An EC2 instance operates within a VPC. Its subnet, route tables, security groups, network ACLs, and available gateways influence whether it can communicate with:
- Other instances in the VPC
- Managed AWS services
- On-premises networks
- The public internet
A public IP address alone does not guarantee connectivity. Routing and security controls must also permit the traffic. Conversely, instances without public exposure can still access external services through appropriate private networking or egress architecture.
Pricing is a design decision
EC2 pricing models are relevant both operationally and in certification scenarios. The appropriate model depends on how predictable, flexible, and interruptible the workload is.
Common categories include:
- On-Demand Instances: Flexible usage without a long-term commitment; useful for variable or short-lived workloads.
- Reserved Instances or Savings Plans: Commitment-based purchasing approaches for workloads with predictable usage. The precise commitment and flexibility differ by option.
- Spot Instances: Uses spare AWS capacity at a discount, but instances can be interrupted. Suitable for fault-tolerant, distributed, or checkpointed workloads.
- Dedicated options: Provide isolation characteristics or host-level control for requirements involving licensing, compliance, or tenancy.
The least expensive hourly rate is not automatically the correct choice. A workload that cannot tolerate interruption may incur greater operational cost if placed on an unsuitable pricing model.
Exam-Relevant Takeaways
- EC2 provides virtual servers, but a complete design also includes an AMI, instance type, storage, networking, security, and pricing model.
- Choose an instance type based on workload characteristics rather than selecting the largest available size.
- Distinguish operating-system configuration from instance hardware configuration. The AMI primarily establishes the OS and initial software; the instance type determines compute characteristics.
- Treat storage persistence and instance lifecycle separately. Data that must survive instance replacement needs an appropriate persistent storage strategy.
- A public IP address does not replace VPC routing or security-group configuration.
- Use interruption-tolerant architectures when considering Spot Instances.
- Pricing questions commonly test whether workload behavior matches the pricing commitment: predictable usage favors commitments, while flexible or interruptible processing can favor Spot.
- EC2 is a building block used in many broader AWS architectures, so decisions about EC2 often affect availability, security, operations, and cost simultaneously.
Architecture Decision Guide
| Requirement | EC2 design consideration | Main tradeoff |
|---|---|---|
| Run a general-purpose application | Select an AMI and instance type matching CPU, memory, storage, and network needs | Flexibility versus operational management |
| Support a predictable baseline workload | Consider a commitment-based purchasing option | Lower effective cost versus reduced flexibility |
| Process interruptible batch jobs | Consider Spot capacity with retries, checkpointing, or distributed workers | Lower cost versus possible interruption |
| Preserve application data across instance replacement | Use persistent storage and a recovery or backup strategy | Durability and management overhead versus simplicity |
| Restrict an instance from public exposure | Place it in a private subnet and provide only required private or egress paths | Improved exposure profile versus more networking components |
| Allow internet-facing access | Configure public routing, address assignment, and tightly scoped security controls | Reachability versus increased attack surface |
| Run different operating systems | Select an AMI and instance configuration compatible with the required OS | OS compatibility, licensing, and operational differences |
Common Exam Traps
- Confusing an AMI with an instance type: The AMI supplies the operating system and software image; the instance type supplies the virtual hardware profile.
- Assuming public IP means public access: Internet access also requires correct route tables and security controls.
- Using Spot for an interruption-sensitive workload: Spot capacity can be reclaimed. The application must tolerate interruption.
- Ignoring data persistence: Replacing an instance can affect local or instance-associated data. Persistent business data requires an explicit storage design.
- Choosing pricing before understanding workload behavior: First determine whether usage is steady, variable, short-lived, or interruptible; then select the pricing approach.
- Treating EC2 as only a compute decision: Storage, network placement, IAM permissions, security groups, and operations are all part of the architecture.
Real-World Engineer Notes
- Start EC2 design with workload requirements: CPU, memory, storage performance, network throughput, operating system, availability, and interruption tolerance.
- Separate stateless application tiers from stateful data services where possible. Stateless instances are easier to replace, scale, and recover.
- Document the intended lifecycle of every data volume: temporary, persistent, replicated, backed up, or disposable.
- Prefer private connectivity for internal application components and expose only the endpoints that genuinely require public access.
- Treat pricing as an operational commitment. A discount is valuable only when the workload’s usage pattern and availability requirements support it.
- Use monitoring and testing to validate that the selected instance family and storage configuration match actual workload behavior.
Quick Reference Summary
- Amazon EC2: AWS virtual servers.
- AMI: Operating system and initial software image used to launch an instance.
- Instance type: Defines the virtualized compute and related resource characteristics.
- Storage: Supports boot, application data, logs, and recovery requirements; persistence must be intentional.
- Networking: VPC placement, routing, IP addressing, and security controls determine communication.
- Pricing: On-Demand provides flexibility; commitments suit predictable usage; Spot suits interruption-tolerant workloads.
- Architecture principle: Select EC2 components together rather than optimizing one dimension in isolation.
Flashcards
- Q: What is Amazon EC2?
A: A service for running virtual servers in AWS.
- Q: What does an AMI provide?
A: The operating system and initial software configuration used to launch an EC2 instance.
- Q: What does an EC2 instance type primarily define?
A: The virtual compute profile, including resources such as vCPU, memory, and networking characteristics.
- Q: What are major EC2 deployment decisions besides instance type?
A: AMI, storage, VPC and subnet placement, IP addressing, security, and pricing model.
- Q: Why is storage persistence important in EC2 design?
A: Instance replacement or lifecycle events can affect data unless data is stored and recovered using an appropriate persistent strategy.
- Q: Does assigning a public IP automatically make an EC2 application reachable?
A: No. Routing and security controls must also permit the traffic.
- Q: When is Spot capacity generally appropriate?
A: For workloads that can tolerate interruption, such as resilient batch or distributed processing jobs.
- Q: When is a commitment-based EC2 pricing option generally appropriate?
A: When the workload has predictable, sustained usage and the organization can accept the associated commitment.
- Q: What is the relationship between EC2 and a VPC?
A: EC2 instances are launched into VPC subnets, and VPC networking controls their connectivity.
- Q: Why should EC2 be studied as more than a virtual machine service?
A: EC2 designs combine compute, image management, storage, networking, security, operations, and cost decisions.
Practice Questions
Question 1
A company runs a batch-processing application on EC2. Jobs can be retried from checkpoints, and losing a worker does not affect the overall result. The company wants to reduce compute cost. Which approach is most appropriate?
A. Use only On-Demand Instances because batch processing must never stop
B. Use Spot Instances with checkpointing and retry logic
C. Assign public IP addresses to all workers
D. Use a larger instance type regardless of utilization
Correct answer: B
Explanation: The workload is explicitly interruption-tolerant and can resume from checkpoints, making Spot capacity a suitable cost-optimization option.
Question 2
An architect launches an EC2 instance with the correct AMI but discovers that the application has insufficient memory. Which change most directly addresses the problem?
A. Replace the AMI with an image containing a different operating system
B. Change the VPC route table
C. Select an instance type with an appropriate memory profile
D. Assign an Elastic IP address
Correct answer: C
Explanation: The instance type determines the virtual hardware profile, including memory. The AMI primarily determines the operating system and initial software.
Question 3
An EC2 instance has a public IPv4 address, but users cannot connect to the application from the internet. Which statement best explains the situation?
A. A public IP always requires an Elastic IP to work
B. Public addressing alone is insufficient; routing and security controls must also allow the traffic
C. EC2 instances cannot receive internet traffic
D. The AMI must be changed to a Windows image
Correct answer: B
Explanation: Internet reachability depends on the subnet’s routing, gateway configuration, and security controls in addition to the address assignment.
Question 4
A business runs an EC2-based service continuously with stable usage throughout the year. It wants to reduce the effective compute cost and can make a usage commitment. Which pricing direction should the architect evaluate?
A. Spot capacity only
B. A commitment-based option such as Savings Plans or Reserved Instances
C. On-Demand only because predictable workloads cannot use discounts
D. Dedicated Hosts for every instance
Correct answer: B
Explanation: Predictable, sustained usage is a candidate for commitment-based pricing. Spot is less appropriate when interruption cannot be accepted, while dedicated tenancy addresses different requirements.
Question 5
An application stores important customer data on an EC2 host. The architecture team plans to replace instances during deployments and failure recovery. What should the team establish before implementation?
A. A persistent storage and backup or recovery strategy for the data
B. A larger public IP address
C. A different security group only
D. A Spot pricing model for the data volume
Correct answer: A
Explanation: Instance replacement should not determine whether important data survives. The data requires an explicit persistent storage and recovery design independent of the instance lifecycle.