Search code examples
amazon-web-servicesaws-lambdaamazon-ecsserverlessaws-fargate

Is AWS Fargate true serverless like Lambda? Does it automatically shutsdown when it finishes the task?


This really wasn't clear for me in the Docs. And the console configuration is very confusing.

Will a Docker Cluster running in Fargate mode behind a Load Balancer shutdown and not charge me while it's not being used?

What about cold starts? Do I need to care about this in Fargate like in Lambda?

Is it less horizontal than Lambda? A lambda hooked to API Gateway will spawn a new function for every concurrent request, will Fargate do this too? Or will the load balancer decide it?

I've been running Flask/Django applications in Lambda for some time (Using Serverless/Zappa), are there any benefits in migrating them to Fargate?

It seems to be that it is more expensive than Lambda but if the Lambda limitations are not a problem then Lambda should always be the better choice right?


Solution

  • Will a Docker Cluster running in Fargate mode behind a Load Balancer shutdown and not charge me while it's not being used?

    • This will depend on how you configure your AutoScaling Group. If you allow it to scale down to 0 then yes.

    What about cold starts? Do I need to care about this in Fargate like in Lambda?

    Is it less horizontal than Lambda? A lambda hooked to API Gateway will spawn a new function for every concurrent request, will Fargate do this too? Or will the load balancer decide it?

    • ECS will not create a new instance for every concurrent request,any scaling will be done off the AutoScaling group. The load balancer doesnt have any control over scaling, it will exclusively just balance load. However the metrics which it can give can be used to help determine if scaling is needed

    I've been running Flask/Django applications in Lambda for some time (Using Serverless/Zappa), are there any benefits in migrating them to Fargate?

    • I havent used Flask or Django, but the main reason people tend to migrate over to serverless is to remove the need to maintain the scaling of servers, this inc managing instance types, cluster scheduling, optimizing cluster utilization

    @abdullahkhawer i agree to his view on sticking to lambdas. Unless you require something to always be running and always being used 99% of the time lambdas will be cheaper than running a VM.

    For a pricing example

    1 t2.medium on demand EC2 instance = ~$36/month

    2 Million invocations of a 256MB 3 second running lambda = $0.42/month