Skip to content

Instantly share code, notes, and snippets.

@ross-humphrey
Last active March 2, 2020 06:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ross-humphrey/8518d40b00945431ad523b32398e8931 to your computer and use it in GitHub Desktop.
Save ross-humphrey/8518d40b00945431ad523b32398e8931 to your computer and use it in GitHub Desktop.
πŸ‘©β€πŸŒΎ Fargate Vs EC2

Fargate vs EC2

Adapted from this great article

  • Fargate runs docker containers serverless. Fargate utilizes Docker containers and runs them virtually.
  • Fargate allows you to run containers without having to manage servers or clusters.
  • No need to scale, provision or configure clusters of virtual machines to run containers.
  • No need to choose server types and how they communicate

Two modes

  • Fargate launch type
  • Pack application in containers, specify the memory/CPU requirements, define IAM or network polocies and launch app.
  • EC2 launch type
  • Define server level, more granular control over the infrastructure, allows you to find best server for app based on requirementss

Benefits:

  • No cluster management
  • Seamless scaling
  • Integration with Amazon ECS
  • Abstracts infrastructure = secure container deployments - embed maximum security within a container.
  • Lower the costs
    • Charges for particular time span app workloads are running
    • Able to determine the right number of containers to run on any given host
    • Roughly 10% cost reduction
  • Reduces complexity

How does Fargate Work?

  • Build the container image in the first step
  • Define resources and images needed for app
  • Launch containers and fargate manages infrastructure
  • AWS runs containers, scales and manages availability

EC2 vs Fargate

Pricing

  • EC2 launch type - billing is based on underlying EC2 instances
  • EC2 launch type - optimize the process by taking advantage of billing models like spot instances / reserved
  • EC2 launch type - customer responsibility to make sure that containers are densely packed onto instances to get max cost benefit . You pay per second - minimum of a minute

Use Cases

  • Workload is consistent for CPU or memory - run EC2
  • Large cluster of EC2 instances is harder to maintain - if you cant handle it use Fargate
  • Small workload - Fargate
  • Small test environment - Fargate
  • Conisstent periodic tasks from a queue - Fargate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment