Things are changing. Technology differences between serverless and container-based systems are rapidly blurring.
In 2020, Amazon Web Services (AWS) enabled AWS Lambda to package and deploy functions as container images instead of bundling all of a function’s code and dependencies in a .zip file. Today, more organizations are increasingly deploying Lambda functions as Docker container images.
These companies want to reap the benefits of serverless computing, containers, and container orchestration. Thus, while AWS Lambda and AWS Fargate are distinct serverless solutions, more companies are using functions (Lambda) with containers, while others want more control over runtime environments using Fargate.
This guide will make sense of this shift by comparing AWS Fargate vs. Lambda in more detail, taking multiple aspects into account, such as performance, security, and pricing.
What Is AWS Fargate?
The AWS Fargate service allows you to run containerized apps on the AWS public cloud with minimal infrastructure management.
Fargate is a serverless compute solution that enables you to focus on container-level tasks, such as setting access controls and resource parameters, instead of more time-consuming tasks, like provisioning, setting up, updating, securing, and scaling clusters of Elastic Compute Cloud (EC2) servers or virtual machines.

Credit: Define container parameters with Fargate – TechTarget
Here’s how running containers in AWS with Elastic Compute Cloud (EC2) instances works:

Now, here’s how AWS Fargate introduces serverless computing into container management in AWS:

From the image, Fargate abstracts away many of the tasks you’d otherwise need to handle manually from the image.
You don’t need to choose the right server types, manually scale instances, or patch many issues. AWS handles that for you. Your primary focus is optimizing your code for optimal service delivery, which increases productivity, eases management, and optimizes operational costs.
All this also makes Fargate primarily a Container-as-a-Service (CaaS) offering. It works as an operational mode in Amazon Elastic Container Service (ECS) for Docker-based containers.
Fargate also seamlessly integrates with the Elastic Kubernetes Service (Amazon EKS) for Kubernetes-based containers. Each EKS pod or ECS task runs in its own isolated, dedicated runtime environment, further securing it.
What Is AWS Lambda?
With AWS Lambda, you can run code as functions without managing the underlying AWS infrastructure. Lambda is an event-driven compute service that automatically executes tasks in response to compute event triggers.
A Lambda function is a small program that performs a specific task. It executes when specific events occur in other AWS services, such as when an object is added to an Amazon S3 bucket. Some call this Function-as-a-Service (FaaS), although the Lambda ecosystem goes beyond that.
Each function runs in an isolated environment with its own file system view and resources. Also, the FaaS approach lets your cloud provider manage most infrastructure tasks compared to CaaS. Check this out:

Once you write code (6 languages supported) and upload it, AWS Lambda manages most other tasks necessary for running the containerized app, such as booking a cloud provider’s server resources, patching security issues, and scaling compute resources.
Here are more comparisons between Lambda and Fargate.
AWS Fargate Vs. Lambda: Navigating Their Differences
AWS Fargate and AWS Lambda are powerful serverless options that serve different needs. Here is how they compare:
Cost
At CloudZero, we treat cost as a first-class metric, so we’ll start with comparing Fargate vs. Lambda pricing. Both services use a pay-as-you-go model, where you pay for only the resources you use — not idle capacity.
Also, note that Fargate and Lambda use entirely different billing models, so comparing them side-by-side is tricky — but we’ll do our best.
AWS Lambda charges you per invocation and duration of each invocation, whereas AWS Fargate pricing is based on the resources and region your containerized applications use per second. But there’s more to it.
AWS Lambda pricing
Lambda pricing does not charge by server units. Instead, Lambda billing is based on:
- Number of requests AWS served your functions, and;
- The time it takes your functions to execute your code (duration)
Lambda will count a request every time it begins executing in response to an invoke call or event notification trigger. It then calculates the duration between the time your Lambda function (or code) starts to execute and when it ends or returns rounded off to the nearest 1 millisecond.
Billing occurs in 1-millisecond increments. The actual price per duration depends on how much memory you allocate.

Credit: AWS Lambda pricing calculator
With Lambda, you can choose how much memory your function needs using the AWS Lambda resource model. Lambda will automatically assign your function a corresponding amount of CPU and other resources. This happens each time you change your memory configuration.
For Provisioned Concurrency, Lambda counts:
- The amount of concurrency you configure, and
- The duration you configure it
Enabling Provisioned Concurrency for your functions will also charge you for responses and duration. How much you pay per request and duration depends on your region/location, although most regions have the same rate.
One more thing. Lambda functions that run on Graviton2 processors using AWS’ Arm architecture can save up to 34% of costs compared to X86-based architecture processors when running workloads such as data and media processing, web, and mobile backends.
Want to learn more about AWS Lambda billing, including examples and calculations in one place?
Check out our Lambda pricing guide here.
AWS Fargate pricing
Fargate prices are per second, and there is no upfront charge. AWS Fargate will bill you based on the amount of vCPU, RAM, OS, CPU architecture, and storage your containerized apps consume while running on EKS or ECS.
For now, you’ll want to confirm the specifics of your setup. As of this writing, Windows OS, storage resources, and Arm CPU architecture are only available through the Amazon ECS implementation.
Fargate calculates resource usage from the time you start downloading a container image until the ECS task or EKS pod ends. It then rounds off the cost to the nearest second. Also, note that there’s a one-minute minimum charge (15 minutes minimum for Windows containers).
Something else. AWS Fargate pricing also varies by region, as do most other services on the AWS public cloud. For example, the cost per vCPU (Linux or X86) and GB per hour in the US East (Northern Virginia) is $0.04048 and $0.004445, respectively.

Compare that to $0.04456 per vCPU per hour (Linux or X86) and $0.004865 per GB per hour in Canada (Central).
Additional costs apply for data transfers. Using other AWS services with Fargate also costs extra, like monitoring Fargate with Amazon CloudWatch Logs.
However, Fargate lets you use AWS Savings Plans (up to 50% off Fargate On-Demand pricing) and AWS Fargate Spot (up to 72%).
If you want to learn more about AWS Fargate pricing, we have a guide on how much Fargate really costs here.
Key takeaway: It is tempting to compare Lambda and Fargate pricing head-to-head. But that might not be the best way to go about it. To find out which service best suits your workload requirements and budget, we recommend you review the remaining comparison points below.
Setup and Maintenance
With Fargate, you package your app in containers, configure the Operating System, vCPU, RAM parameters, networking, and Identity Access Management policies, then launch it.
Fargate enables you to run ECS tasks and services using the Fargate deployment type or a Fargate capacity provider. AWS handles the rest, including allocating a base CPU and RAM to run your containers.
Lambda hosts and runs your code on a highly available computing infrastructure. With Lambda, you only manage the application code and functions. AWS handles everything else, including hardware, virtualization, and runtime. Those tasks also include scaling up or down, servers performing OS maintenance, provisioning RAM and vCPU capacity, and monitoring logs.
With Lambda, you can write, deploy, and run your code as functions, which is the closest thing to serverless computing.
Key takeaway: Overall, AWS Lambda requires much less work to set up and run than AWS Fargate. However, Fargate hands you more control over your container runtime than Lambda.
Development
AWS Lambda lets you write, upload, and deploy code for virtually any app or backend service. You’ll need to write your code in Node.js, Python, Ruby, Java, Go, or C#. Alternatively, code compilers like Maven and Gradle or packages can also help you build functions in Lambda.
You can also deploy Docker images with Lambda.
In addition, you can use other programming languages in Lambda by implementing a custom runtime. A runtime interface handles invocation events and responses in Lambda’s execution environment. You can deploy a custom runtime along with your function code — or as a compute layer.
With AWS Fargate, you get a serverless compute layer for containers that work in an operational mode in Amazon EKS (Kubernetes-based containers) or iECS (Docker-based containers).
Fargate also supports various runtime environments, and you have more control over compute capacity allocation when you register your containers with ECS. With Lambda, you are limited to uploading a 250MB deployment package to S3, 10GB when using container images, and 10GB of available disk space.
Another thing. To use Fargate with ECS, you must define tasks, text files in JSON format, to define your containers. Fargate lets you define up to 10 containers. These definitions empower you to configure your app’s parameters, including OS options (Amazon Linux 2 or Windows 2019 or 2022), the containers to use, the ports to open, and the amount of data for each container.
Key takeaway: With Fargate and Lambda, you don’t have to choose the right server types, manually scale instances, or patch many issues in development or production. But if you need more control over your setup, AWS Fargate affords you that compared to AWS Lambda.
Performance
Before April 2022, AWS Fargate deployments took five minutes or more, while AWS Lambda deployments took seconds. Scaling up resources also took longer, especially when requests spiked suddenly.
Fargate can now scale up to 500 tasks per service within two minutes when you use the ECS service scheduler to handle long-running apps. Previously, it would have taken 15 minutes to do that at a steady state.

Credit: AWS Fargate task launch rate
In addition, Fargate supports bursting up to 100 On-Demand or Spot tasks using ECS RunTask API for periodic or one-time batch jobs. This means you can launch tasks at a sustainable 20 tasks per second rate, which is 20X faster than in 2021 and earlier (60 to 90 seconds).
However, because of other factors, like load balancing and health monitoring, Fargate may take a little longer to launch and scale tasks:

Even though Fargate still takes longer to start up than Lambda, it is still faster than before and ECS. Mostly, this is due to Fargate’s need to wait for the underlying ECS clusters to wake up.
AWS Lambda automatically spins up storage and compute resources when a function is called. Besides scaling from 0 to 1000 quickly, Lambda can also scale back to 0 just as fast. This makes Lambda ideal for handling unpredictable traffic spikes or requests.
Fargate does not natively scale to zero, although you can shut it down to save costs. Not scaling to zero means Fargate remains warm, minimizing cold start-induced latencies. But since Fargate scales capacity in a stair-step process, Lambda is often faster in this regard.
Also, Fargate does not support GPUs or tasks that require more than 10 GB of disk storage per container, although this is still far more than Lambda’s 512 MB.
Lambda, however, has no maximum concurrency limits. Although, by default, it is set (by AWS) to 1,000 (you can request more by making a service limit change request to AWS).
After stopping, Lambda functions often suffer cold starts (up to 5 seconds), which may be a concern for latency-sensitive tasks but negligible for many other tasks. Various ways can counter the latency, and once the system is warmed up, the issue becomes insignificant as it becomes more efficient.
There is one more thing. The memory limit for a Lambda function is 3GB. AWS does not allow you to select CPU capacity either. Instead, it assigns CPU capacity based on RAM selection.
Fargate, on the other hand, provides a maximum of 30 GB of RAM and 4 vCPUs for all applications.
Key takeaway: AWS has improved both Lambda and Fargate over the years. You may need to spend more time tuning Fargate to start up and scale as quickly or rapidly as Lambda. But once Fargate is running, it doesn’t experience latency and offers a more reliable option than Lambda for long-running apps.
Monitoring
AWS Lambda provides out-of-the-box setup for monitoring logs, metrics, traces, alarms, and dashboards. The service automatically sends monitoring metrics to AWS CloudWatch for visualization and reporting.

AWS Lambda monitoring with CloudWatch
Lambda monitoring includes graphs on invocations, min/average/max duration that function code spends processing an event, percentage of successful and errored invocations, times an invocation failed due to concurrency limits (throttles), iterator Age, number of concurrent executions, and async delivery failures.
Still, it can be challenging to perform granular Lambda monitoring because there isn’t an underlying server to run monitoring agents. You may need to output application metrics within functions to boost visibility, which can incur additional costs in data transfer and execution time. But you can leverage plenty of tools like Thundra, SumoLogic, and AWS X-Ray for that.
For AWS Fargate monitoring, you can still forward monitoring metrics to Amazon CloudWatch and AWS App Mesh.
Using CloudWatch Container Insights, you can collect, aggregate, and summarize metrics and log data from your AWS ECS and AWS EKS apps. App Mesh abstracts monitoring and routing. This eliminates the need to keep updating the application code. With App Mesh, each service exports monitoring data and applies logic to support consistent exchanges across your application.
Fargate also provides CloudWatch utilization metrics corresponding to AWS service quotas for Fargate On-Demand consumption. You can view your consumption on a graph through the Service Quotas console and set alarms to notify you when your usage nears a service quota.
Ultimately, most monitoring tools that work with Amazon ECS will also support AWS Fargate. In addition, you can use third-party tools like Instana, DataDog, and CloudZero to monitor Fargate more granularly.
Key takeaway: While AWS Lambda automatically pushes logs to CloudWatch, you may need to configure AWS Fargate manually to do the same, including setting up resource usage alarms and dashboards.
Security
Lambda and Fargate abstract most infrastructure responsibilities away. But security remains an area where AWS encourages shared responsibility. Both services are inherently secure, but the notable difference is how you set up and execute Identity Access Management (IAM) roles in Lambda and Fargate.
Lambda allows you to set up IAM roles for each function or service. With AWS IAM modules, only allowed users can access functions. In addition, each function runs in an isolated environment.
In Fargate, security permissions are tied to containers or pods where tasks run. Each Fargate task runs in its own isolated compute environment, sharing no underlying resources such as CPU/memory, kernel, or elastic network interface with other tasks.
For app security with Fargate, you can integrate it with AWS Secret Manager or AWS Systems Manager Parameter Store to pull the credentials. You can expose the secrets as environment variables in your container.
Key takeaway: Lambda and Fargate both offer built-in security. You still need to do your part to secure your functions and containers. This is especially true for Fargate because it gives you more control, which can increase security misconfiguration. Tools like Sysdig can help you secure your Fargate container deployments from source to run.
Use Cases
With time, Fargate and Lambda have become increasingly capable of handling similar workloads. But, as you’ve seen, each is stronger in certain areas.
With Lambda, you get seamless, speedy, and automated scaling, a fully managed serverless solution, out-of-the-box logs monitoring, and a compute solution for temporary tasks, among other Lambda use cases. Yet Lambda’s cold start issue might make it unsuitable for latency-sensitive tasks.
With Fargate, you can run long-running containerized tasks, choose your runtime environment, and experience fewer limitations over vCPU, RAM, and ephemeral storage usage. That is in exchange for registering and updating containers in Amazon ECS, configuring Fargate resources, and monitoring them yourself.
Although ECS offers maximum configurability, it is also the most complex to implement. At the other end of that spectrum is AWS Lambda, a full-fledged serverless computing service (nearly no management complexity but offers minimal control). AWS Fargate sits somewhere in the middle.
Key takeaway: Compared to Lambda, Fargate offers more control and lower costs, while AWS does most of the heavy lifting for you.
How To Measure, Monitor, And Control AWS Lambda And Fargate Costs
Using AWS Lambda or AWS Fargate not only relieves you of managing clusters of servers but can also lower your AWS costs compared to using Amazon ECS. The problem with serverless infrastructure is that it’s often difficult to visualize, analyze, and optimize costs.
It’s critical to have a platform that can accurately collect, analyze, and report serverless resource usage metrics. However, most cost management tools aren’t up to the job; they require you to update cost allocation tags continually.
With CloudZero, you can accurately track AWS Lambda or AWS Fargate costs without tagging. We’ve also built CloudZero on serverless infrastructure as more of an observability tool than a mere cost tool. This provides you with continuous cost insight into metrics you care about: cost per customer, cost per software feature, cost per team, cost per product, and more.

You can also track your containerized and non-containerized costs down to the hour, cluster, namespace, and pod.

CloudZero maps costs to the people, products, and processes that generate your costs. You can then pinpoint where to optimize costs to improve your margins. CloudZero also monitors your Fargate and Lambda deployments in real time and notifies you of cost anomalies to prevent overspending.
But don’t just take our word for it. to see CloudZero in action!
FAQs
What is the main difference between AWS Fargate and AWS Lambda?
AWS Fargate is a serverless compute engine for running containers without managing servers, ideal for long-running applications. In contrast, AWS Lambda is a serverless compute service that runs code in response to events, suitable for short-lived, event-driven tasks.
Can AWS Lambda handle long-running processes?
AWS Lambda has a maximum execution timeout of 15 minutes per function invocation, making it unsuitable for long-running processes. For such tasks, AWS Fargate is more appropriate.
How do AWS Fargate and AWS Lambda handle scaling?
Both services offer automatic scaling. AWS Lambda scales automatically in response to incoming events. AWS Fargate scales by adjusting the number of running containers based on demand.
What are the security considerations for AWS Fargate and AWS Lambda?
Both services operate under AWS’s shared responsibility model. AWS Lambda runs functions in isolated environments with IAM roles per function. AWS Fargate enhances security by isolating each task in its own compute environment, with IAM roles tied to containers or pods.
Which service should I choose for event-driven applications?
AWS Lambda is ideal for event-driven applications due to its ability to execute code from various AWS services in response to events.
Can I use AWS Fargate and AWS Lambda together in my architecture?
Yes, many architectures benefit from using both services together, leveraging AWS Lambda for event-driven functions and AWS Fargate for long-running, containerized workloads.