AWS

[AWS] EC2 vs ECS vs Lambda

brightlightkim 2022. 3. 24. 05:00
  • EC2 (Elastic Cloud Compute) >> Manage Infrastructure
    • Pros
      • Manage Instances up or down
        • bring down or tear down when it's needed
      • Memory, Compute, Cloud Optimization
        • Different Sizes
      • Extremely Flexible
    • Cons
      • Security (in and out)
    • How?
      • Load Balancers (LG) - hit this first
        • Target Groups (TG)
          • Auto Scling Groups (ASG) - EC2 feeling the traffic
  • ECS (Docker Eco System)
    • EC2 Machine (Clusters + Tasks)
      • Treat a pool of ECS as Abstract Resources
        • and deploy tasks to these clusters >> long living or one off
      • Clusters paired with EC2
      • Elastic Container Repository: Private Hub to maintain it.
    • Operating on Docker Systems
    • Diagram
      • Load Balancer
        • Hit the Load Balancer first
      • Clusters
        • Fargate (alternative options)
        • 2 EC2 Machines
          • Agents (EC2)
          • Docker Containers

  • Lambda
    • Operate at the Function levels
      • Unit of Code (Don't have to worry about the infrastructure)
      • Upload some codes fo console 
    • Abstract lots of complexities
    • ARN
    • Lambda SDK and invoke it. >> load all functions
      • Powerful Concept (we don't have to worrry about the infrastructure)
    • EX:
      • Upload Lambda Function
        • Shielding you from Load Balancer, Docker Container, and EC2 Machine
      • Connect it with GateWay (API)
        • User Request >> for ward it to Lambda Function
    • Pros
      • Solve problems with complexity

 

How to Choose?

  • Flexibility and Knowledge you have
  • Large Flexibile + Complexity + Knows everything
    • EC2
      • High Degree of Management
  • ECS: Pretty Fair Middle Ground
    • Abstract
    • Cluster manage EC2 Machine >> bring containers up or down.
  • Lambda
    • Tradeoffs
    • 30 min max invocation time for the single lambda time
    • Paying for number of invocations and duration and space
    • Less Control over how your application runs.
  •