What is Fargate?
AWS Fargate is an implementation of a Container Engine, and allows you to run your containers without provisioning or managing servers. You only pay for the time your containers are running. It’s used by the Containers orchestrators – ECS(Elastic Compute Services) and EKS(Elastic Kubernetes Services).
Why do you get savings?
The alternative to Fargate is a group of EC2 instances. With an EC2 instance, you pay for the compute engine all the time it’s switched on, even if there are no containers on them.
In the following scenarios you might want to go with FarGate:
- There are many peaks (or there are scheduled batch jobs)
- For a tiny workload (on experimental and dev environments)
- To reduce the overhead of managing servers
Fargate is not recommended for steady or big predictable workloads. In such cases, it would be cheaper running the EC2 on Spot or Reserved Instances.
What other benefits do you get?
- Simplicity of infrastructure management – AWS manages the instances underneath. You won’t even know they exist! You won’t need to scale up or down the cluster, the placement of containers into nodes is also fully transparent.
- Security by default, as the attack vector is reduced considerably. There is no need to protect any server, just configure the services.
- You can use the standard Kubernetes API to orchestrate the containers (all the service offerings are not available).
- Fargate implements another layer of isolation that might protect the containers from noisy neighbors.
- Also, for Security, granting permissions to Fargate clusters is more secure with Roles than deploying the service account credentials into servers.
How hard is it to migrate to Fargate?
If the application is already in containers, and it doesn’t require persistent storage, then, you’re ready. In general, these applications are not good candidates for moving to containers:
- Very old legacy ones (mainframe-based or written in proprietary languages),
- Badly designed ones (super-monolithic), or
- Applications depending on non-cloud friendly storage solutions (like local databases/Sqlite, Lucene).
The good news is that you can try to use “Fat Containers”, such as those generated by tools like App2Container. They help with migration to the containers world. The local storage problem can be worked out by using EFS for Fargate (available since April 2020).
Once we have our application living in containers, based on the scenarios described above, it’s possible to make a choice about Fargate. Using a tool to calculate the break-even point helps immensely with decision making.
Further reading: Moving to Serverless with Lambda