Amazon Web Services (AWS) Compute: Which Works Best for You?

You’ve built an amazing web app and you’re ready to deploy it to the cloud. After signing up with Amazon Web Services (AWS), you’re quickly overwhelmed with options for running your app. All these options fall under the category of “Compute.” Let’s explore each so you can make an informed decision.

EC2 (Elastic Cloud Compute)

This is the heart of the compute architecture where you can provision individual server instances, which are essentially computers running in the cloud. You can choose the OS (Windows, various Linux distros, or even Mac), memory and number of cores, and size of the drive. Like any new computer, you have to install any software you want running by logging in remotely.

For example, these servers can host web applications such as WordPress; or they can host the production software you’re building. Or they can serve as development environments where you run your devtools and connect through Remote Desktop or the Linux equivalent, VNC.

  • Pros: You have complete control over the machine.
  • Cons: You have to do everything manually: Install whatever software you want on the server; set up the firewalls; and so on. You’re charged by the hour, and if you’re not careful, you can get hit with a huge bill at the end of the month.

Elastic Beanstalk

This is the ultimate in hold-your-hand architecture. In years past, it was pretty basic and limited, but today it has significant features, providing a perfect starting place to launch scalable applications. Through a handy set of tools (either command-line or through the AWS web console), you can easily deploy your own web application in any of several languages, including node.js, Java, C#, and more.

  • Pros: Incredibly easy to use. Services are provisioned automatically.
  • Cons: You have to be very aware of the services it launches, especially those that you’re charged hourly for. For example, launching an app will result in the provisioning of a server on EC2. If you’re not aware of the servers and don’t properly shut them down when you’re finished, you could end up with a larger bill than you expected.

Lambda

Lambda is a way to run applications in a so-called serverless environment. Whereas Elastic Beanstalk uses your own EC2 instances as servers, Lambda is considered “serverless” in that AWS manages the servers used by any apps you run in Lambda. Technically there is a server (code can’t just run in the air), but you don’t have to worry about creating the server, and you’ll neither see it in the console or manage it.

One important aspect of Lambda is you don’t just start an app and leave it running continuously. Rather, Lambda code runs in bursts. You provide the code to run in the form of a code function (in your language of choice) and then specify triggers that will cause your function to run. What type of triggers? It’s a long list, but one example is an API call coming from, say, a web browser or other computer requesting data you’re providing. The list is long, and you can even listen for events coming from an Amazon Alexa.

  • Pros: You don’t have to worry about provisioning the hardware yourself. AWS will scale your Lambda code as needed, meaning you don’t have to worry about how to scale. Your Lambda code also has full access to the whole array of AWS services, such as databases you create in AWS RDS and files you store in AWS S3. This can be very cost-effective.
  • Cons: Lambda is difficult to use correctly, but not by any means impossible. You must code your Lambda functions in a manner that multiple instances of the function might run simultaneously. There’s also a limit on how long a single function can run; in 2022, that limit is 15 minutes.

Lambda’s pricing is a bit confusing, and instead of trying to describe it here, we’ll just send you to the FAQ. In general, however, Lambda functions can be quite budget-friendly.

EKS and ECS (Elastic Kubernetes Service, Elastic Container Service)

These are services for managing and orchestrating docker containers. ECS was the original container service for AWS, and in recent years AWS has added Kubernetes support.

If you’re interested in using either EKS or ECS, you need to understand where the running containers reside, as you have a choice. You can have them reside on EC2 instances in your own account. Alternatively, you can run them “serverless” using a service called Fargate whereby AWS allocates the containers themselves, and you pay for the virtual CPU and memory resources needed by the container (which can potentially be much less than the virtual CPU and memory allocated on EC2 instances hosting your containers).

But again, you’ll want to check AWS’s official FAQs on pricing. Here you’ll find ECS pricing and here you’ll find EKS pricing.

  • Pros: You get to use containers and all the benefits that come from them. For example, you can run multiple versions of the same software, each in its own container, if you have such a need. (This actually happens often; for example, different apps might need different versions of a MySQL database.)
  • Cons: You have to fully understand Docker images and containers, which can have a steep learning curve. Additionally, if you’re using EKS, you’ll need some knowledge of Kubernetes, which can take some time learning. And finally, you have to manage the scaling of the containers. (Compare that to App Runner, which we cover next.)

App Runner

This is another container service, but with much less configuration on your end. Probably the single biggest aspect is how the containers scale (that is, get replicated) on demand. You don’t have to worry about it. For example, if you have an app that doesn’t get a large amount of traffic, but only occasionally needs bursts (such as only certain days of the week), then App Runner can be ideal, as it will scale automatically for you. And when there isn’t much traffic, fewer instances will run, saving you money.

  • Pros: Easy to use and manage, and potentially money-saving compared to ECS and EKS.
  • Cons: Less configuration available compared to ECS and EKS.

Regarding EKS, ECS, and App Runner: for smaller apps, you’ll likely want to use App Runner. If you have a large app that has enormous traffic all day, every day, then you’ll likely want to use EKS or ECS.

Other Compute Services

AWS offers more compute services for highly specialized use cases:

  • AWS Outposts: This service extends EKS and ECS to your own premises, which means the containers run on servers in your own data center (which, to be frank, most small app shops don’t have, so we won’t cover that here).
  • Serverless Application Repository: This isn’t so much a compute service as a repository of pre-coded applications that are easy to deploy into serverless environments such as Lambda.
  • Lightsail: This is sort of a “lite” version of EC2. You can provision a server that’s preconfigured with a set of software such as WordPress. Lightsail isn’t meant for anything heavy-duty such as running your own custom apps; it’s primarily a simpler version of EC2.

Conclusion

In the earlier days of AWS, your best bet was to simply provision your servers yourself and install the software manually. Those days are long past, and AWS now has multiple services that are much easier to use. These services can, when used properly, also save you a good amount of money.

Before you decide which Compute service is best for your job, you need to first fully understand the different offerings and their pros and cons. The best way is to practice: Try creating an app on Lambda and integrating it with a database, and allow it to be called through the Amazon API Gateway (which is a service that listens for incoming HTTP API requests and can trigger Lambda functions). Try building an app with Elastic Beanstalk. Compare how they work. Try creating an app inside a docker container and push it up to ECS, EKS, or App Runner.

After experimenting for a bit, compare these efforts and see which service best fits your needs and budget. Learn as much as you can and you’ll be ready to take an AWS Certification exam or land your next AWS developer job.