1.4.1. Compute Services: EC2, Lambda, Fargate (Lean List)
š” First Principle: AWS offers diverse compute services, each built on distinct operational models to address specific workload needs, balancing control, scalability, and cost.
AWS offers diverse compute services, each built on distinct first principles to address specific workload needs:
- EC2 (Elastic Compute Cloud): Provides resizable virtual servers with granular control over the operating system and software. Ideal for traditional server deployments, custom OS, or persistent workloads needing dedicated resources.
- Lambda (AWS Lambda): A serverless compute service that runs your code in response to events and automatically manages the underlying compute resources for you. Suited for event-driven architectures, scalable serverless applications, and microservices responding to triggers. Cost-effective for intermittent workloads.
- Fargate (AWS Fargate): A serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Eliminates managing underlying EC2 instances for containerized apps. Simplifies operational overhead, ideal for microservices or batch jobs focusing on container deployment.
Key Compute Services & Characteristics:
- "EC2": Virtual servers, full control, pay-per-hour.
- "Lambda": Serverless functions, event-driven, pay-per-invocation.
- "Fargate": Serverless containers, no server management, pay-per-resource.
Scenario: You need to choose a compute service for a new web application. It requires a traditional web server setup for static content and an API backend that processes short-lived, event-driven requests.
ā ļø Common Pitfall: Using EC2 for short-lived, event-driven tasks that could be handled more cost-effectively by Lambda.
Key Trade-Offs:
- Control (EC2) vs. Managed Overhead (Lambda/Fargate): EC2 offers maximum control but requires more management. Lambda and Fargate abstract infrastructure, reducing operational burden but limiting control.
Reflection Question: How would you choose between EC2 (for the web server) and Lambda (for the API backend) to meet the diverse compute needs of this application, considering their distinct operational models and cost structures?