Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fargate vs Lambda, when to use which?

I'm pretty new to the whole Serverless landscape, and am trying to wrap my head around when to use Fargate vs Lambda.

I am aware that Fargate is a serverless subset of ECS, and Lambda is serverless as well but driven by events. But I'd like to be able to explain the two paradigms in simple terms to other folks that are familiar with containers but not that much with AWS and serverless.

Currently we have a couple of physical servers in charge of receiving text files, parsing them out, and populating several db tables with the results. Based on my understanding, I think this would be a use case better suited for Lambda because the process that parses out the text files is triggered by a schedule, is not long running, and ramps down when not in use.

However, if we were to port over one of our servers that receive API calls, we would probably want to use Fargate because we would always need at least one instance of the image up and running.

In terms of containers, and in very general terms would it be safe to say that if the container is designed to do:

docker run <some_input> 

Then it is a job for Lambda.

But if the container is designed to do something like:

docker run --expose 80 

Then it is a job for Fargate.

Is this a good analogy?

like image 763
janDro Avatar asked Sep 11 '18 11:09

janDro


People also ask

When should I use fargate?

When to use AWS Fargate. Fargate is a great tool when you start building a new application and you don't want any operational overhead. Using Fargate, you only pay for the resources you use and you can iterate much faster.

What is AWS fargate good for?

AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers. AWS Fargate is compatible with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS).

Can Lambda call fargate?

The Lambda function invokes a Fargate task that takes care of the code scan.

Which is better EC2 or fargate?

Fargate is the better option for ease of use as it takes infrastructure management out of the equation allowing you to focus on just the tasks to be run. It works great for most workloads and enables a faster pace of operations.


1 Answers

That's the start of a good analogy. However Lambda also has limitations in terms of available CPU and RAM, and a maximum run time of 15 minutes per invocation. So anything that needs more resources, or needs to run for longer than 15 minutes, would be a better fit for Fargate.

Also I'm not sure why you say something is a better fit for Fargate because you "always need at least one instance running". Lambda+API Gateway is a great fit for API calls. API Gateway is always ready to receive the API call and it will then invoke a Lambda function to process it (if the response isn't already cached).

like image 106
Mark B Avatar answered Oct 02 '22 19:10

Mark B