System Design — Choosing between AWS Lambda and AWS Fargate

Kanika Modi
AWS in Plain English
3 min readJul 24, 2021

--

Back with the System Design Choices series, in this blog post, I explore AWS Lambda vs AWS Fargate, showing the benefits and drawbacks of each system and which one to select based on your system design requirements.

Why AWS Lambda

AWS Lambda is an event-driven, serverless computing platform that is, it runs your code in response to events and automatically manages the underlying compute resources for you.

  • Serverless
  • Widely supported and easy to setup
  • Logging, metrics & dashboards available out of the box
  • Automatic scaling and high availability without additional effort
  • Self-service administration console
  • Supports Java, Python, Node.js, etc.
  • Easy integration with other AWS Services
  • Comparatively low cost when used at low scale
  • Limits on function configuration like memory, concurrency, etc.
  • Cold start issue

Why AWS Fargate

AWS Fargate is a serverless compute engine for containers that work with both AWS ECS and AWS EKS. Fargate makes it easy for you to focus on designing and building your applications instead of managing the infrastructure that runs them.

  • Run containers without having to provision, configure, manage servers or clusters
  • Auto-scaling based on CPU/Memory utilization metrics which are auto-generated
  • High Availability
  • Does not support GPUs
  • Support workloads requiring less than 10 GB of disk space per container
  • Support workloads requiring less than 4 vCPU or 30 GB memory per container
  • High-Cost Solution
  • No out-of-box setup for logs, alarms, and dashboards

When to select Lambda

  • When you have event-driven workloads, that is, when the application needs to trigger action on an event.
  • When your application requires the ability to handle unknown demand.
  • When you need managed operational and administrative activities like monitoring fleet health, applying security patches to the underlying compute resources, monitoring and logging your code, etc.
  • When you need managed provisioning, capacity scaling, high availability, and utilization.
  • When your application deployment package size ≤ 50 MB and execution time ≤ 15 minutes.
  • When you are focused on cost optimization.

Lambda is designed for compute applications that are triggered by an event. For example, an SNS message being received, a call to an API, when an S3 object is updated, a cron job, etc.

When to select Fargate

  • When your application is latency-sensitive.
  • When your application needs inter-container communication or is storage-intensive.
  • When you need support for long-running scheduled jobs (>15 mins).
  • When your application serves predictable high customer traffic.
  • When you need more choices on the runtime environment.
  • When you have a large/batch workload and you’re looking for less operation load.
  • When you don’t need complete control of your compute instances but need control of the compute environment — CPU and memory configs.

Streaming, high-frequency polling, or caching applications are a great fit for Fargate, allowing longer live persistence of data, without having to manage hardware directly.

Thank you for reading! If you found this helpful, here are some next steps you can take:

  1. This blog is part of the System Design Choices series. Check out the other blogs of the series.
  2. Send some claps my way!
  3. Connect with me on Medium, LinkedIn & Twitter for more tech blogs!

More content at plainenglish.io

--

--

Software Engineer @amazon | Designing Systems At Scale | Tech & Career Blogs | She/Her | ViewsMine()