Quick guide to select the right compute service in AWS
You want to deploy a web server, a microservice, or simply run a script. But when you look at the AWS compute options, you’re presented with a long list of choices: Fargate, Batch, EC2, Lambda, and more. It can be tough to know which one is the best fit for your workload.
This guide will help you make sense of the different AWS compute options and choose the one that’s right for you.
All of the AWS compute services can run your programs, but each has its own advantages, disadvantages, and limitations. Let’s take a look at each service to see what it’s best for.
Lambda: Run code serverless. Note that serverless in this context is not “without a server”, since there is always a server. It means “without caring about maintaining a server”. However, Lambda is only suitable for light workloads, as it has a limited execution time. So only light workloads are suitable for Lambda. The bright side is that you can run multiple lambdas at the same time (aka horizontal scaling). Another advantage is that you pay only when it is active. When there is no traffic, there is no cost. Some typical usage:
Backend for web applications, event-driven processing, IoT, bots.
You have several programing language to choose from (Python, NodeJS, .Net and more) and even the option to use your own custom image. The main limitation is that is not easy to run applications that needs special OS libraries. If this is what you need, you may consider using another AWS Compute service.
EC2: A Virtual Machine (VM) on the cloud. You select the type of CPUs (or even GPUs), amount of RAM and vCPUs. You can also select the OS, from most mainstream OS up to specialized Linux distributions. In EC2 you have complete control of the software you run. You pay when the instance is on, even when you are not getting traffic. EC2 can be used for a wider range of workloads than Lambda, including heavy workloads. Typical usage for EC2: Web servers, Database servers, Application servers, Machine learning, DevOps, Testing.
Fargate: AWS Fargate is a serverless compute engine for containers that enables you to run containers without having to manage servers or clusters. Fargate takes care of provisioning and managing the compute resources for your containers, so you can focus on building your applications.
Fargate is compatible with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). This means that you can use Fargate with either of these container orchestration services to manage your containers.
Is a good choice for stateless workloads that have unpredictable traffic patterns. This is because Fargate can automatically scale your containers up or down as needed.
Typical usage: Stateless workloads, Cost-sensitive workloads, Developers who are new to container orchestration. If your software is already containerized, you should consider Fargate.
AWS Batch: A fully managed batch computing service that lets you run batch jobs on AWS without having to manage servers or clusters. Batch jobs are long-running, compute-intensive tasks that are typically not interactive.
Batch uses Fargate or EC2 to run containers, so you can use it for the same reasons you would use Fargate. The main difference is that Batch provides automation features that can help you manage your batch jobs more easily.
Some typical use cases for Batch include data processing, machine learning, video processing, scientific computing, and others.
Let’s take a look at some typical applications and the options you have for running them.
A Telegram (or WhatsApp) bot: This is a reactive application that needs an incoming message to activate. While you can use any of the mentioned services, AWS Lambda is the most suitable service. This is because Lambda is a serverless compute service that can be triggered by events, such as an incoming message. This means that you don’t have to worry about provisioning or managing servers, and your bot will only be triggered when it needs to be.
A corporate web server: This type of application requires 24/7 availability and the ability to run any arbitrary software. AWS EC2 is the most suitable service for this application. This is because EC2 provides you with virtual machines that you can customize to meet the specific needs of your application. You can also choose the instance type that best meets your performance and cost requirements. You can also consider LightSail, that is an EC2 like service, easier to use with less options, that is comparable with Virtual Private Hosting offered by Linode and Digital Ocean
Scientific software that is already containerized: Fargate and batch are the main options for this scenario. Fargate lets you run containers without having to manage servers or clusters. This makes it a good option for scientific software that is already containerized, as you don’t have to worry about provisioning or managing infrastructure.
I hope this guide has helped you understand the different AWS compute options and choose the one that’s right for you. Remember, the best way to decide is to consider your specific needs and requirements. If you’re not sure which service is right for you, you can always contact AWS support for help.
Here are some additional tips for choosing the right AWS compute service:
- Start with your requirements: What are the specific needs of your workload? Do you need a serverless compute service, or do you need more control over the infrastructure?
- Consider your budget: How much are you willing to spend on compute? Some services, such as Lambda, are pay-as-you-go, while others, such as EC2, have upfront costs.
- Think about your workload’s performance: How much performance do you need? Some services, such as Fargate, are designed for stateless workloads, while others, such as EC2, can be used for more demanding workloads.
- Take into account your team’s skills: Do you have the skills to manage a serverless compute service, or do you need a more hands-on approach?
By considering these factors, you can choose the AWS compute service that’s right for your needs.