Since Fargate does not show you instances how do I know if it is packing in additional tasks on the same underlying instance in order to avoid additional cost? Or does a single Fargate task represent a single instance and will be charged as such? If that is the case then EC2 launch type is a WAY cheaper option if trying to cram multiple tasks onto a single instance.
Why do you care?
Fargate is a managed container service.
There is no reason to care whether or not the underlying instance is running other Services and Tasks. That’s up to AWS to decide as the managed service provider.
Because I don’t want to be charged for each task. With EC2 type you’re only charged for the insurance no matter how many tasks are running on it. Seems like Fargate charges you per task. That’s what I’m trying to confirm.
You pay for resources, not number of tasks https://aws.amazon.com/fargate/pricing/
So each task on Fargate has an isolation boundary:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html
Each Fargate task has its own isolation boundary and does not share the underlying kernel, CPU resources, memory resources, or elastic network interface with another task.
So CPU and memory for a task will not be shared with another task. Each task can be said to run on its own host.
But in terms of cost, EC2 launch type would be cheaper. Fargate is a managed service where you don’t have to worry about capacity provisioning or maintenance, so it does cost a bit more. You can also over provision containers on EC2. Fargate should not be considered when trying to maximize costs, but for minimizing management overhead.
Edit: to confirm, you are charged per task on fargate
You are not charged per task. You are charged based on the resources you are using (vCPU, ram), per second.
This might help.
https://aws.amazon.com/fargate/pricing/
ECS supports Fargate AND EC2 Compute Options. So, if you want, you can have ECS orchestrate your containers on EC2 in your VPC.
Keep in mind one thing … If you run on EC2, you are responsible for operating those instances. This includes patching, sizing, and, instance maintenance. Lots of labor that you don’t need to worry about with Fargate.
It’s the task that uses the resources so you are charged per task. It’s vCPU times the number of tasks.
I am reading ECS pricing and I don’t see any mentioning of task quantity - only resources. So, if you run 2 tasks 2Gb RAM each, you would pay the same as if you would run 4 tasks 1 Gb each or 1 task with 4 Gb. No?
Correct. It’s not technically per task but logically per task because the task is the multiplier in the case of Fargate. But for the EC2 type, you’re only charged for the instance no matter how many tasks are running on it. That’s what I mean when I say it’s charged per task.
EC2 is potentially cheaper: if your tasks pack well onto the instance type(s) you use, you can definitely beat Fargate but I’ve also seen people running a bunch of under-utilized instances because they deployed a container which needed enough RAM that it was one per VM and so they had a bunch of VMs at like 60% RAM / 5% CPU.
The bigger question: what’s your time worth? If you run instances, you have to maintain them. That’s not a huge burden with ECS but try to express it in terms of your hourly rate with context switching overhead to see how much you need to save before you break even.
You’re not getting it. If you want to pay by EC2, use EC2 ECS. If you want to pay by resource/task and not worry about additional complexity, use Fargate.
If you want to share CPU/memory between tasks use the EC2 type.
If, for example, you have a number of continuously running tasks that use a small amount of resources, you are probably better off using EC2 instead of fargate.
Fargate is more expensive then running ECS on EC2 instances from a pure AWS spend perspective. However Linux OS management and Linux teams are expensive and by not wasting resources on OS and server management you overall spend could be reduced for the management of your app.
Hi, this is talked about in AWS re:Invent 2020 here:
In short, no. Each underlying VM only runs 1 single task and the VMs are never allocated on the same physical hardware nor same ENI.
Pricing is based on requested vCPU, memory, Operating Systems, CPU Architecture, and storage1 resources for the Task or Pod. The five dimensions are independently configurable.
I’m assuming this is where the idea of being charged per task comes from.
For analogy. Imagine you have 100ml of water. You can pay $1 for each ml of water or you can pay .95 for a 100 ml glass of water. You would think that the glass is the better option and you’d be right only if you never need more than 100ml of water and never less than 95ml of water.
Fargate pricing is like paying for each ml while ec2 would be buying a glass. The example above used easy small numbers, but we know in the real world it’s never so predictable.
So yes per documentation
Pricing is based on requested vCPU, memory, Operating Systems, CPU Architecture, and storage1 resources for the Task or Pod. The five dimensions are independently configurable.
You are charged per task or pod, but is it cheaper to use ec2? Like every architecture question should be answered, it depends. Ec2 spot instance prices can get stupid low, but are you ok with outages? If so then yes a well managed ec2 instance can be cheaper on your aws bill, but could be more expensive if not optimized. Plus how much do you pay yourself to manage it?
You have received a lot of down votes for this question, that’s really a shame since you came asking questions. But from an architecture standpoint, any time you make a broad assumptions like “x is cheaper than y” then there is going to be some passionate discourse for sure.
Late here but no.
Source: have worked for Fargate for years