Use EC2 for traditional applications with full OS access.
Use containers for applications with a microservices architecture; choose between ECS or EKS for container orchestration, and choose between EC2 or Fargate for running the containers
Use AWS Lambda for event-driven, serverless functions.
At this point, you've covered a few different AWS compute services. It cane be quite overwhelming to learn so many new concepts, so let's recap and play a fun game!
By the end of this recap, you'll feel much more confident about when to use each compute service.
We will present three different use cases that require compute on AWS, and it's up to you to choose the right service for the use case.
Ready? Let's go!
SET THE SCENE
Consider a scenario where you are a developer who is tasked with creating a new feature for a web application being hosted on EC2:
YOUR TASK
Automate the process of getting the new item information loaded into the inventory database.
YOUR GOAL
To have a person upload an inventory spreadsheet into Amazon S3, your object storage service, then have a process automatically load the data into the inventory database.
What compute would you use to host the processing logic* to load the items from the spreadsheet into the database?
*Processing logic = the set of instructions or code that specifies how this task is done.
Pause here now. What do you think?
.
.
.
.
.
Promise us you've paused and had a proper think about this!
.
.
.
.
.
(Pinky promise)
.
.
.
Are you ready? The answer is right under this line!
You could have decided to use Amazon EC2 here. It's possible.
AWS Lambda is the correct answer for this one.
SET THE SCENE
Let's say you have an application hosted in your on-premises data centre. It's currently running on Linux servers in the data centre.
YOUR TASK
Migrate the on-premise data centre onto AWS.
YOUR GOAL
You want to minimise the amount of refactoring* needed to migrate to AWS. It's important that this workload is elastic and can support different levels of demand.
*Refactoring = making significant changes to the code to adapt it for a new environment or platform. It's like remodelling a house to fit new furniture or appliances – in this case, it's about modifying the software to fit the AWS platform.
What compute option would you choose?
Time to pause!
.
.
.
.
.
.
(pinky promise you've had a think about this)
.
.
.
.
.
Are you ready? The answer is right under this line!
Considering the fact that minimising refactoring is important, the best option is Amazon EC2.
AWS Lambda could work, but you can't just upload the same code you would run on EC2 into a Lambda function. There would have to be a decent amount of refactoring to take advantage of that service. Same idea with any of the AWS container services, like ECS or EKS. You'd have some amount of rework required to migrate to containers. Since minimising refactoring is your goal, EC2 is the best option.
YOUR TASK
You are planning to write a brand-new application using a microservices design.
YOUR GOAL
Which AWS compute service would you use?
Time to pause!
.
.
.
.
.
.
(pinky promise you've had a think about this)
.
.
.
.
.
Are you ready? The answer is right under this line!
One of the AWS container services like Amazon ECS or Amazon EKS is best for this.
As we're well aware now, AWS offers a brand range of compute offerings - virtual machines (VMs), containers, and serverless.
Remember that these services exist to best suit different use cases helps.
Don't try to use the same compute service for all of your use cases. Instead, pick the right one for the job, and consider reevaluating choices for existing workloads as AWS continues to release and improve offerings.