Need advice about which tool to choose?Ask the StackShare community!
AWS Fargate vs AWS Lambda: What are the differences?
Key Differences Between AWS Fargate and AWS Lambda
AWS Fargate and AWS Lambda are both serverless technologies offered by Amazon Web Services (AWS) that allow developers to focus on writing code without managing the underlying infrastructure. However, there are several key differences between the two services that are important to note:
-
Deployment Model:
- AWS Fargate: Fargate provides a container-centric serverless compute engine, where developers package their application into containers and specify the resources needed for each container. These containers are then scheduled and managed by Fargate.
- AWS Lambda: Lambda, on the other hand, operates on a function-centric serverless model, where developers write and upload individual functions that automatically scale and run in response to events. Lambda takes care of the execution environment and handles the scaling and resource allocation for each function.
-
Runtime Execution:
- AWS Fargate: With Fargate, applications run continuously and are responsible for handling their own state and concurrency. They can leverage features like web servers, persistent storage, and background processes.
- AWS Lambda: Lambda functions are event-driven and typically have a short duration. They are stateless and designed to handle a single request at a time. Lambda automatically manages any concurrency and scaling requirements.
-
Cost Model:
- AWS Fargate: Fargate operates on a pay-per-use pricing model, where customers are charged based on the amount of CPU and memory resources their containers consume and the duration of their runtime.
- AWS Lambda: Lambda also follows a pay-per-use pricing model, but it is based on the number of invocations and the amount of time each function takes to execute. Lambda functions are billed in 100ms increments.
-
Supported Use Cases:
- AWS Fargate: Fargate is suitable for long-running applications, microservices, and batch processing workloads that require more control over the execution environment, the ability to run containers with specific resource requirements, and persistent storage.
- AWS Lambda: Lambda is well-suited for event-driven architectures, serverless web applications, and stream processing use cases. It excels in scenarios where functions can be triggered by various AWS services, such as S3, DynamoDB, or API Gateway.
-
Integration and Ecosystem:
- AWS Fargate: Fargate integrates seamlessly with other AWS services, allowing developers to take advantage of features like Elastic Load Balancers, Amazon VPC, and AWS CloudFormation. It also works well in conjunction with container orchestration platforms like Amazon ECS and Kubernetes.
- AWS Lambda: Lambda has extensive integrations with AWS services, enabling developers to easily build serverless architectures that leverage services like S3, DynamoDB, SNS, and more. It also supports a variety of event sources, including HTTP endpoints, CloudWatch Events, and S3.
-
Flexibility and Control:
- AWS Fargate: Fargate offers more control and flexibility over the underlying infrastructure and resources. Developers have the ability to specify CPU and memory requirements for their containers, as well as configure networking and security settings.
- AWS Lambda: Lambda abstracts away the underlying infrastructure, providing a highly managed environment. Developers have less control over the execution context and resource allocation, but benefit from the automatic scaling and availability provided by the service.
In summary, AWS Fargate is a container-centric serverless compute engine that allows developers to run and manage containers, while AWS Lambda is a function-centric serverless compute service that executes individual functions in response to events. Fargate provides more control over the infrastructure and supports long-running applications, while Lambda excels in event-driven use cases and integrates seamlessly with other AWS services.
When adding a new feature to Checkly rearchitecting some older piece, I tend to pick Heroku for rolling it out. But not always, because sometimes I pick AWS Lambda . The short story:
- Developer Experience trumps everything.
- AWS Lambda is cheap. Up to a limit though. This impact not only your wallet.
- If you need geographic spread, AWS is lonely at the top.
Recently, I was doing a brainstorm at a startup here in Berlin on the future of their infrastructure. They were ready to move on from their initial, almost 100% Ec2 + Chef based setup. Everything was on the table. But we crossed out a lot quite quickly:
- Pure, uncut, self hosted Kubernetes — way too much complexity
- Managed Kubernetes in various flavors — still too much complexity
- Zeit — Maybe, but no Docker support
- Elastic Beanstalk — Maybe, bit old but does the job
- Heroku
- Lambda
It became clear a mix of PaaS and FaaS was the way to go. What a surprise! That is exactly what I use for Checkly! But when do you pick which model?
I chopped that question up into the following categories:
- Developer Experience / DX 🤓
- Ops Experience / OX 🐂 (?)
- Cost 💵
- Lock in 🔐
Read the full post linked below for all details
Pros of AWS Fargate
Pros of AWS Lambda
- No infrastructure129
- Cheap83
- Quick70
- Stateless59
- No deploy, no server, great sleep47
- AWS Lambda went down taking many sites with it12
- Event Driven Governance6
- Extensive API6
- Auto scale and cost effective6
- Easy to deploy6
- VPC Support5
- Integrated with various AWS services3
Sign up to add or upvote prosMake informed product decisions
Cons of AWS Fargate
- Expensive2
Cons of AWS Lambda
- Cant execute ruby or go7
- Compute time limited3
- Can't execute PHP w/o significant effort1