Lambda or Fargate

Can someone help me understand when should I use lambda and when should I use Fargate? I need to process a file that does not have size limit. I know that lambda does have a time limit of 15 minutes. I am not sure if lambda is a good choice here , considering I will have to launch multiple lambdas to process the entire file. The other option is Fargate. I am not really sure which one to use. Can someone help me here?

Fargate and ECS should be used for containerized architecture. Lambda should be used to complete a task in AWS.

If you don’t actually need the file locally (for instance, if you’re just reading metadata from a video file, say), or can split it, the you can process it in lambda. If you can split it, this older re:invent talk

might be interesting.

Otherwise, you’ll probably run into time and space limits if you have really large files, like in the 10gb and up range, and should go with fargate.

Another point to consider. The fargate cpu tends to be faster than lambda. Run some benchmarks if this matters to you.

So much faster that a client went with 4 fargate cores instead of 6 lambda cores as the fargate instances finished the tasks they were running in half the time.

What do you mean by “6 lambda cores”?

Lambda doesn’t let you choose cores etc. and memory is the only setting (which is a proxy to other things, but they don’t share the details)?

Use 10GB to get 6. https://aws.amazon.com/about-aws/whats-new/2020/12/aws-lambda-supports-10gb-memory-6-vcpu-cores-lambda-functions/

If you’re processing files like a bulk data processing system ETL style, I’d suggest looking at Glue or Batch instead. While I’ve had lots of problems with Glue, it provides an abstraction that is purely focused on data processing and hides details about file loading, distributed systems away.

I would avoid Lambda in this case because you then end up in the world of building an orchestrator on top of Lambda. What happens if one part of the file fails? Do you execute in series or parallel? How do you know when the file is done? What happens if the file grows? How do you segment?

A lot of this may only go wrong when you’ve been running in production for a while, then you’re putting duct tape on it fixing this issue or that issue.