DEV Community

Jully Achenchi
Jully Achenchi

Posted on • Edited on

30 Days of AWS- Part 2: AWS Compute

Welcome to part 2 of 8 of this series "30 days of AWS". While each article delves into a different aspect of AWS, rest assured that they are all interconnected and are building blocks to any given solution.

AWS compute is powered by several services that accomplish different tasks. These services are:

  • Amazon Elastic Cloud Compute (EC2)
  • AWS Lambda
  • AWS Elastic Beanstalk
  • Amazon EC2 Auto Scaling
  • Amazon Elastic Container Registry
  • Amazon Elastic Container Services
  • Amazon Fargate
  • Amazon Elastic Kubernetes Services
  • Amazon Lightsail

In this article, my focus will be on Amazon EC2 and we will look at:

  • EC2 instances - Types, pricing, and use cases.
  • AWS global infrastructure - Regions, Availability zones, and edge locations
  • Provisioning 2 EC2 instances in different availability zones in the same region

What is an EC2 instance?

An EC2 instance is a virtual server that allows users to run applications in the AWS cloud.

What is a server?
A server is a computer program or device that provides a service to another computer program and its users, also known as the client

Types of EC2 instances

EC2 instances are divided into 5 categories.

The table below summarizes the instance types, their characteristics, and examples.

Instance type Characteristics Instance families
1. General purpose instances - The computation, memory, and networking resources in general-purpose instances are balanced M7, M6, M5, Mac, T2 and T3 families
2. Compute-optimized instances - Great for compute-intensive tasks that require high-performance processor
Suitable for applications that demand high CPU power. C5, C6, and C7 families
3. Memory-optimized instances - These instances are geared for workloads that need huge datasets to be processed in memory. Memory here means RAM which allows us to do multiple tasks at the same time. X1, X2, High Memory, R5, R6, R7, and R8 families.
4. Storage optimized instances - Great for storage-intensive tasks that require high, sequential read and write access to huge datasets I4, I3, D2, D3, and H1
5. Accelerated computing - These instances provide the highest performance in Amazon EC2 for deep learning and high-performance computing (HPC). P2, P3, P4, P5, G3, G4, G5, G6, Trn1, Inf1, Inf2, DL1, DL2q, F1, and VT1

Amazon EC2 pricing models

1. On-demand instances

  • You pay for what you use
  • It has the highest cost and no upfront payment is made.
  • It is recommended for short-term and un-interrupted workloads, where you can’t predict how an application will behave

2. Reserved instances

  • Reserved instances are a flexible pricing option and help reduce costs compared to On-Demand prices by committing to a specified amount of usage for a 1 or 3-year term.
  • You can save up to 72% compared to On-Demand prices with the discounted savings plan rate.
  • Recommended for steady-state usage application.

3. Spot instances

  • Spot instances allow you to use unused EC2 capacity in the AWS cloud and can offer up to 90% off on-demand prices.
  • Instances run as long as they are available and they can be interrupted at any time by AWS.
  • It is best used for workloads that can withstand interruptions. You are given a 2-minute notice before interruptions.

4. Dedicated hosts

  • This is a physical server with an EC2 instance capacity fully dedicated to your use

AWS Global Infrastructure

The AWS Global Cloud Infrastructure is the underlying structure that allows AWS to serve cloud computing services to customers all over the world.

It is segmented into AWS regions, availability zones, and edge locations

AWS Regions

An AWS Region is a physical location in the world where we have multiple Availability Zones

Currently, there are 33 regions across the globe, with 6 regions in the works.source

Availability zones

Availability Zones consist of one or more discrete data centers, each with redundant power, networking, and connectivity, housed in separate facilities.

Availability zones are many miles apart to reduce the risk of correlated failures.

This page gives a comprehensive live of the AZs in the different regions.

Currently, there are 105 availability zones and plans for 18 more. source

Edge locations

Edge locations are used for content delivery- Static content is replicated to those locations in order to reduce latency. There is no computing that goes on in Edge Locations, just storage of data.

Key services that leverage AWS Edge Locations include Amazon CloudFront, and Amazon Route 53.

Differences between edge locations and availability zones

Edge locations Availability zones
Edge locations are used for caching content and delivering it at low latency and high performance Availability zones are used to ensure high availability and fault tolerance of services by providing physically separate data centers within a region.
Edge locations are spread out geographically and are separate from AWS regions AWS availability zones are distinct, physically separate data centers within a specific AWS Region

Launch an EC2 instance

Onto the sweeter part

We are going to launch 2 instances in two different availability zones in the same region

To choose your region:

  • On the top right corner of the AWS management console, right before your account name, there is a drop-down to choose your preferred region to launch your instance.

  • I'll be using the 'us-east-1' region and availability zones 'us-east-1a and us-east-1b'

Steps to launch an EC2 instance

  1. Login to your AWS management console
  2. On the top right corner, in the search bar search EC2. It should come up. This is the EC2 dashboard

Search ec2 instance on management console

  1. Click on the "Launch Instance" button on the dashboard

Click launch instance button

The next page will be as follows. This is where you give the specifics of your instance such as:

  • The name of your instance e.g my_first_instance
  • The Amazon Machine Image - This is a template that contains the software configuration required to launch your instance such as the operating system, application server, and applications. There are thousands of AMIs to choose from. You are spoilt for choice. However, keep in mind that whatever AMI you choose comes with a bill. For this demo, we'll go with 'Amazon Linux 2023 AMI'. It's well within the free-tier umbrella.

Name and AMI of your instance

  • Instance type - The choice of instance will depend on your preference and workload. Each instance comes with a different combination of CPU, and memory. For this demo, we'll use the t2.micro

Instance type and key-value pair

  • Key -pair. A key pair is what is used to connect to an instance. For now, we'll select 'proceed without a key pair'

  • Network settings such as VPC, subnets, and security groups (there is an in-depth explanation in part 5 of this series).

VPC - A VPC (Virtual Private Cloud) is a virtual networking environment

Subnet - A subnet is a range of IP addresses in your VPC. A subnet resides in a single Availability zone. This is how you're able to have multiple instances in different AZs in the same region

Security group - An AWS security group acts as a virtual firewall for your EC2 instance(s) to control incoming and outgoing traffic.

  • Click on the "Edit" button in network settings
  • In the subnet dropdown, choose the subnet that resides in your desired AZ, in this case, us-east-1a as shown below.

choose a subnet in your desired AZ

  • Storage - T2.micro allows for a maximum of 30GB of storage

Provide storage
That's it. Click the "Launch instance" button. Viola! your first instance in region us-east-1 and AZ us-east-1a is up and running.

instance in AZ us-east-1a

To launch a second instance in AZ us-east-1b, give your instance a name, choose the AMI, the instance type, and choose a subnet in AZ us-east-1b as shown below

Instance 2

Final results:

Final results

Thank you for making it to the end. I hope you've learnt a thing or two.

See you in the next one.

Top comments (0)