5

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?

Mojimi
  • 2,561
  • 9
  • 52
  • 116
  • Good question. Most resources say serverless is when your code only runs when it is needed to process a request (because they use Lambda as an example). I think it really means the managing of a server is abstracted. As proven by Fargate with EKS, if you didn't set 0 pods as minimum, then a pod is always running. – wilmol Aug 22 '21 at 09:09

2 Answers2

6

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

JohnB
  • 808
  • 6
  • 12
4

With AWS Fargate, you pay only for the amount of vCPU and memory resources that your containerized application requests from the time your container images are pulled until the AWS ECS Task (running in Fargate mode) terminates. A minimum charge of 1 minute applies. So, you pay until your Task (a group of containers) is running, more like AWS EC2 but on a per-minute basis and unlike AWS Lambda where you pay per request/invocation.

AWS Fargate doesn't spawn containers on every request as in AWS Lambda. AWS Fargate works by simply running containers on a fleet of AWS EC2 instances internally managed by AWS.

AWS Fargate now supports the ability to run tasks on a scheduled basis and in response to AWS CloudWatch Events. This makes it easier to launch and stop container services that you need to run only at a certain time to save money.

Keeping in mind your use case, if your applications are not making any problems in the production environment due to any AWS Lambda limitations then AWS Lambda is the better choice. If the AWS Lambda is being invoked too much (e.g., more than 1K concurrent invocations at every point of time) in the production environment, then go for AWS EKS or AWS Fargate as AWS Lambda might cost you more.

Abdullah Khawer
  • 4,461
  • 4
  • 29
  • 66
  • Thank you for the answer. I understand that due to the pricing model of Lambda it would be expensive if you have too many concurrent invocations, but then again a Fargate container that handles 1k invocations should be pretty expensive to maintain at a decent speed, no? – Mojimi Jul 23 '19 at 14:31
  • 1
    @Mojimi, AWS Lambda will be expensive if functions will be invoked continuously 24/7 (all the time) and yes, concurrency will increase the bill as well but using AWS Fargate only makes sense when you need your application up and running either always or during a specific period of time (because of the new feature). P.S.: I took 1K invocations as an example. Invocations could be more or less. – Abdullah Khawer Jul 23 '19 at 15:06