Understanding AWS Compute Options Part 1

Understanding AWS Compute Options Part 1
Photo by Tansu Topuzoğlu / Unsplash

EC2 vs. LightSail vs. Elastic Beanstalk.
What are the differences and when to use what?

With cloud eating the world, it is important to understand the different compute options available to deploy applications. It can be quite frustrating to wrap your head around the different services.

This post aims to make it easier and more transparent.

Compute options can be divided into two broad categories: serverless and server-based. This post deals with server-based. We make comparisons and analyze what to choose based on various criteria.

If you are in a hurry you can skip to the wrap up section for a short summary and a nice illustration.

EC2 - flexible and robust cloud server for every need.

Launching an EC2 instance

EC2 stands for Elastic Compute Cloud and was one of the first services offered by AWS. It is a virtual private server (VPS) which in a practical sense is similar to a physical server. Each VPS has its own OS installed but shares the underlying hardware amongst other VPS's. You choose between instance types, either General purpose, Compute optimized, Memory optimized and others. You also choose the instance size which defines the number of vCPUs and memory available.

In short, you are renting servers in the cloud with EC2.

Ease of use:

While it is fairly simple to launch an EC2 instance it is not the easiest way to get started with AWS. There is little preconfiguration (you only choose the OS). Everything must be installed and configured by the developer.

You have to configure networking yourself and set up firewalls and security manually through ACL (access control lists). Things like connecting a database and setting up a load balancer is the developer's responsibility.

Cost:

Since almost everything is the developer's responsibility, this is the cheapest compute option available on AWS. Below is a short overview of the pricing options.

On-demand: As of this writing it costs $3.50/Month to run a t4g.nano instance (2 vCPUs and 0.5 GB RAM).

There are tricks to reduce costs even more by reserving instances.

EC2 Instance Savings Plans: If you know you will be needing a specific instance family (e.g. general purpose) for 1 or 3 years you pay less. For example you get to pay only $47/3 years which is $1.30/Month for a 3 year reservation. However, there are no options to cancel the reservation once made and no option to change the family if requirements change.

Compute Savings Plans offer more flexibility by allowing you to change instance families among other things although you still commit to a specific term (1 or 3 years). This is again cheaper than on-demand prices.

Scalability:

You can set up EC2-Auto scaling groups where you define the minimum and maximum number of EC2 instances. This ensures that there is enough computational power if demand unexpectedly increases.

Maintenance:

Being a server-based option, you the developer needs to take care of everything including software updates and patches.

When to use it:

  1. Cloud migrations (i.e. lift and shift): If you are beginning the transition to the cloud in a lift-and-shift (migrate apps and data without reprogramming software), EC2 is a nice first step. In this case EC2 is the most straightforward option which still gives you the benefit of the cloud. You still retain full flexibility to make custom configurations. Basically, everything is customizable.
  2. No serverless: In cases where serverless options present difficulties EC2 is a viable option. For example if you are required to rewrite parts of some software before running it on serverless infrastructure. Or if you know how to manage a server and want to save costs (serverless on AWS is much more pricy as we will see in a later post).
  3. Atypical workloads: Also, in cases where you need a highly scalable solution that is not the typical web application. So for example high performance computing needs like scientific computing, batch processing workloads or GPU based workloads like machine learning. Also analytics workloads like running Apache Spark or Hadoop.

This is not an exhaustive list. EC2 is a good option if you need a plain old server to play around with.

Elastic beanstalk - for scalable web applications.

Launching a Python environment instance in EBS

The difference between Elastic Beanstalk (EBS) and EC2 is that beanstalk is PaaS (platform as a service) whereas EC2 is a IaaS (Infrastructure as a Service). This means that beanstalk is 'more managed' than EC2. AWS takes care of the underlying OS and runtime. This is explained further below in the maintenance section.

Essentially, you define the environment for your code, whether that is Python, NodeJS or a Docker environment. Then you upload your code and Beanstalk will take care of deploying and configuring the underlying instances for you. It is one step above EC2 in terms of abstraction. Typically, it would be used for hosting web applications in a scalable way.

Ease of use:

Ranks higher than EC2 in ease of use since it is quite easy to set up. Things like load balancers and databases for example can be set up quickly through the web interface when creating a new environment.

Cost:

Similar to EC2.

Scalability:

Similar to EC2 as it includes an auto-scaling group.  

Maintenance:

It scores slightly higher than EC2 here, since there is an option to allow AWS to automatically install minor platform updates and patches for the installed software on your instances. So updating Python or NodeJS versions would be done automatically without you having to worry about it. This service comes at no additional cost.

When to use it:

For web application deployments that need to be scalable. So an application that requires high availability and you expect traffic to grow over a short period of time.

LightSail - quick deployments of simple web applications.

Launching a LightSail instance. Notice how simpler the interface is.

This is also a PaaS like Beanstalk. However the difference is, it comes with a lot of preconfiguration. It is less 'hands-on' offering for instance '1-click- deployments' of Wordpress, the LAMP stack etc. Also, there is no need to manually configure networking, security and databases. It is the quickest and easiest way to get started with AWS. This comes at the cost of reduced flexibility however. Notice in the image above how simpler the interface is compared to EC2 and EBS.

It is also the highest form of abstraction within the server-based options.

Ease of use:

This ranks highest in terms of ease of use and is the most straightforward way to get started with AWS. Want to host a website, a blog or an ecommerce store? But don't want to mess with networking, databases and firewalls? This is the solution for you.

Cost:

This is similar to EC2 although you get slightly less compute power for the price. An instance with 1 vCPU and 0.5 GB of RAM costs $3.43/Month which is roughly the same as for EC2. However, it gets quite pricy if you wish to run Docker containers on your instance. For that, you pay $6.87/Month for 0.25 vCPU and 0.5GB RAM! If your workload requires containers you might need to consider EC2.

Scalability:

Although it is possible to attach a load balancer, LightSail does not support auto-scaling. This means, if your server suddenly gets a lot of traffic or you need more compute resources you need to manually switch to a bigger instance size. This entails taking a snapshot of the current instance, terminating it, and launching a new one. A hassle! It is a manual process.

Finally, LightSail uses AWS burstable instances. These are designed for workloads with traffic 'spikes'. This means if your application is expected to receive a lot of traffic consistently every hour of the day (with high CPU utilization (>80%)) EC2 would be a better choice.

Maintenance:

Similar to EC2 it is server-based so you need to take of updates and patches.

When to use it:

Simple and light to medium workloads such as hosting an ecommerce store, a website or similar. Where you are sure that traffic would not boom immediately.

Wrap-up

To summarize, for web application deployments that expect high consistent traffic use Beanstalk. If you expect low traffic or are setting up a personal site or ecommerce store use LightSail. For everything else and in-between EC2 is the way to go.

Below is a nice table wrapping it up.

Comparison chart for server-based compute options.

Have any questions? Leave a comment below 😇

I hope you liked this post.
Please consider subscribing below to never miss content in the future.