Lambdas are cheap and powerful, what key factor makes you switch?
Comparing AWS Lambda with Docker and Amazon ECS Fargate: Costs, Testing, and Differences
amazon ecs - Fargate vs Lambda, when to use which? - Stack Overflow
When do you draw a line on lambda vs ecs container?
Why we moved from Lambda to ECS
Hi everyone,
I'm fairly new to AWS, and I've been exploring serverless computing with AWS. Specifically, I'm interested in Lambda functions deployed using Docker images. I have a few questions and would appreciate your insights:
-
Differences Between Fargate in ECS and Lambda with Docker:
I understand that Lambda is categorized as FaaS, while ECS Fargate is considered as CaaS. Could someone clarify the key differences and when to use one over the other for specific use cases? -
Cost Implications of Storing Docker Images in ECR:
When we store Docker images in Amazon Elastic Container Registry (ECR), does the cost of image storage significantly impact our overall AWS bill? -
Local Testing with Lambda Using Docker:
One notable advantage of Lambda with Docker is the ability to test functions locally. However, what's the recommended approach when our Lambda function interacts with other AWS services, like updating a database in RDS Aurora? How can we simulate such interactions during local testing?
Thanks in advance for your help!
Looking forward to your responses.
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).
It is important to notice that with Lambda you don't need to build, secure, or maintain a container. You just worry about the code. Now as mentioned already, Lambda has a max run time limit and 3GB memory limit (CPU increases proportionally). Also if it is used sporadically it may need to be pre-warmed (called on a schedule) for extra performance.
Fargate manages docker containers, which you need to define, maintain and secure. If you need more control of what is available in the environment where your code runs, you could potentially use a container (or a server), but that again comes with the management. You also have more options on Memory/CPU size and length of time your run can take to run.
Even for an API server as you mentioned you could put API gateway in front and call Lambda.