Fargate "idle instance"
Hi, Will I be charged for Fargate idle instance? We are going to run activity as Fargate task within a step functions. Scaling parameters
min_count=1 desire_count=1 Max_count=17 Scaling up if average CPU usage more than 50% and scaling down if usage less than 50%.
- The above setup has a min and desire count =1, will we be charged for the CPU/Memory/storage usage 24 hrs a day, 7 days a week? The activity program pulls message from a SQS queue and start processing and on most part of the day, it should be idle.
I understand, there is aws cli command to set desire_count=0 but the messages comes in randomly over the day (i.e., we can not turn desire_count >0 during a period of time and turn it off). Is there a better way to design the system to save cost?
You can additionally start fargate tasks via a Step Function which could be triggered via event bridge/lambda. You would not need a constantly running task in that design
Appreciate the quick response. the task is very much CPU/Memory/Storage bound. We need to run either 2CPU 4GRAM, 100G storage to finish the file processing in 50 mins or 4CPU 8GRam 100G storage to finish processing in 25 mins.
Running Lambda with container plus EFS is not our choice because provisioned throughput cost too much and bursting throughput does not meet our processing requirement either.
With above discussion. Because the long processing time, we can totally tolerate the time to instantiate fargate from 0 count to >1 since the container seems to start pretty quickly (1-2 mins).
- If we are able to have some process listening to some SQS queue or triggered by event bridge and set the desire_count >0 or =0. Would that be a feasible design?
- Can you please point out some AWS ECS/Fargate java api to change desire_count? I see AWSEcsCiient and ECSAsyncClient but these classes creates services/tasks. I am looking for some API to "change" the desire_count.
All suggestions are welcome!
Yes you will be charged at a minimal for the 1 fargate task 24/7.
However for such use cases, Lambda seems to be a better fit. Have you considered it such as using Container Images in Lambda, as shown here?
There is currently an open request on ECS Fargate to scale to 0, which is not generally available yet.
If you have other EKS cluster, Karpenter might be able to help.
Assuming each Task handles a single message at a time, try scaling it using the queue's
ApproximateNumberOfMessagesVisible metric and allow scaling to 0. This assumes also that you can tolerate the latency that will be imposed by auto scaling.
Another option is to trigger a Lambda from the queue that will invoke a Fargate task. To make sure that you do not loose a message in case the task fails, the function can invoke a state machine in StepFunctions to run the task and retry it.
Step functions pass input into Fargate instance :
AWS Step Function Output for container servicesasked 11 days ago
Moving to ECS-Fargate from EC2asked 4 months ago
AWS Fargate Spot - Automated Draining for Spot SupportAccepted Answerasked 2 years ago
Step Function manage/trigger Fargate task container override storage size?
Fargate "idle instance"Accepted Answer
Fargate ephemeral storage 200gb - per task or shared by all tasks?Accepted Answerasked 4 months ago
Trigger Step Function with API Gateway and use Fargate within Step Function?asked 2 months ago
A fargate task schedule via EventBridge fails to launch sometimes with stopReason "Rate limit exceeded while preparing network interface to be attached to instance"asked 4 months ago
Converting a AWS Fargate instance to AWS EC2asked 2 years ago