Amazon Elastic Compute Cloud (EC2)

Spread the love

Hello folks, I hope you are enjoying the journey of the AWS Complete Tutorial Series. Today, we are going to learn one of the important web services of AWS that is: EC2. Hence, I would recommend that if you are just joining this chapter, then please start from the first for this tutorial series by clicking here. All the best.

In this chapter, we will see the following topics of EC2.

  • Introduction of EC2 service
  • Payment models for EC2
  • EC2 instance life cycle
  • Amazon Machine Image(AMI)
  • Creating EC2 Linux machine
  • Connecting to EC2 Linux machine
  • Creating EC2 Windows machine
  • Connecting to EC2 Windows machine
  • Placement group
  • Introduction of Elastic Block Storage (EBS)
  • Types of EBS
  • Root device types
  • Snapshot
  • Create AMI from an existing EC2 instance

Let’s see all of the above topics one by one in detail.

EC2 Introduction:

Amazon’s EC2 is a compute service that provides an on-demand and scalable computing service on the cloud.

With such flexibility in provisioning computing resources, it makes it possible to develop and deploy applications faster.

You can provide as many EC2 instances as you want

If you do not require the provisioned instances, you can terminate them at will.   You can configure security, manage networking, add or remove storage as your business demands.

Few important points:

  Provisioned EC2 resource  – Instance

  AMI = Base OS + Software packages

  You can log in into the instance using key pair ( Private key and Public key)

  Private key – Provisioned to user

  Public key – Resides on an EC2 machine

  Amazon provides temporary and permanent storage for EC2

  Temporary – Instance store

  Permanent – EBS   Security group – Firewall to your instance

Payment models for EC2

There are 4 ways to pay for an EC2 instance:

1. On Demand

  •   Hourly charges
  •   Compute capacity can be increased or decreased
  •   Costliest pricing option
  •   Your partial usage hours will be rounded up and need to pay

  2. Spot instance

  • 90% cheaper than on-demand instance
  • You bid and specify the max price, it will allocate to you accordingly. If current spot instance price increases than your bid price, your instance will be terminated

3. Reserved instance

  •   You can reserve the instance for 1 year or 3 years
  •   You are reserving the instance type, not a specific instance
  •   You can reserve the instance on region and AZ

  4. Dedicated host

  • EC2 machines are physically isolated on dedicated host   3 pricing models – On-demand, reserved and spot instance

EC2 instance life cycle

An EC2 instance passes through various statuses throughout its lifecycle.

It all starts with launching an EC2 instance using a specific AMI.

Amazon Machine Image (AMI):

  • AMI stands for Amazon Machine Image. 
  • AMI is a collection of Operating system + Application server + Application software
  • Also, the block devices that describe volume information needs to be attached to the instance while launching
  • AMI internally stored in S3 but it is not visible in S3 bucket   You can launch multiple instances from one AMI. Also, multiple instances can be launched from multiple AMIs as well.

Creating EC2 Linux machine:

Connecting to EC2 Linux machine:

We will require below 2 utilities to connect with EC2 instance. Download them using the below link and install them in your machine.

  Putty:

https://www.ssh.com/ssh/putty/download

  PuttyGen:

Once you download Putty, you no need to install puttyGen separately.

Just Go to Windows -> Start Menu -> All Programs -> PuTTY -> PuTTYgen.   You will see a window for the PuTTY Key Generator on your screen.

Generating .ppk file from .pem file using PuttyGen

Login into Ec2 machine using generated .ppk file

Creating EC2 windows machine:

Placement group:

A Placement group is a logical grouping of EC2 instances within a single AZ.

Placement group provides a possible lowest network latency across all the EC2
instances that are part of the same placement group.

All EC2 instances do not support high network throughput (that is, placement group).

Before launching an instance in a placement group, you need to ensure that the instance type supports a placement group.

It is best practice to create all the EC2 instances required in a placement group, and ensure they are created in a single launch request and have the same instance type.

In case multiple instance types are mixed in a placement group then the lowest bandwidth among the EC2 instances is considered as the highest network throughput of the placement group.   There is no additional charge for creating an instance group.

Introduction to EBS:

Currently, AWS provides the following types of EBS volumes.

These EBS types have different performance and prices per GB:

  Solid State Drive (SSD):
  General Purpose SSD (gp2)
  Provisioned IOPS SSD (io1)

  Hard Disk Drive (HDD):
  Throughput optimized HDD (st1)
  Cold HDD (sc1)

Previous generation volume:
  Magnetic (Standard)

Types of EBS:

General Purpose SSD(gp2):

Ideal for a number of workloads.

gp2 volumes are very efficient and provide single-digit millisecond latencies

A gp2 volume is capable of bursting up to 3,000 IOPS for a significant amount of time.

You can provide a minimum of 1 GB size of gp2 volume and a maximum of up to 16 TB of a gp2 volume.

gp2 volume provides 3 IOPS per GB of volume size. However, if the volume size is 33.33 GB or less, it provides a minimum of 100 IOPS.

However, a gp2 volume can provide a maximum of 10,000 IOPS.

Provisioned IOPS SSD(io1):

They are intended to address the needs of I/O intensive application workloads.

io1 volumes are specifically used for database workloads that require high-performance storage and consistent throughput.

Unlike gp2 volumes, io1 volume provides a consistent performance.

You can specify a consistent IOPS rate while creating the volume.

An io1 volume size can range between 4 GB to 16 TB. An io1 volume can have a minimum of 100 IOPS and a maximum of up to 20,000 IOPS.

If you use multiple io1 volumes in an instance, AWS imposes a limit of a maximum of 65000 IOPS per instance.

Throughput Optimized HDD (st1)

st1 volumes are architected to measure the performance in terms of throughput and not on IOPS

st1 volume type is recommended for a large and linear workload such as data warehouse, log
processing, Amazon Elastic MapReduce (EMR), and ETL workloads.

It cannot be used as a bootable volume.

 An st1 volume size can range between 500 GB to 16 TB

An st1 volume can have a maximum of 500 IOPS per volumes.

If you use multiple st1 volumes in an instance, AWS imposes a limit of a maximum of 65000
IOPS per instance.

Cold HDD (sc1)

Cold HDD (sc1) volumes are designed to provide a cost-effective magnetic storage option.

sc1 volumes are designed to measure the performance in terms of throughput and not on IOPS.

It’s a good low-cost alternative to st1 if you require infrequent access to your data.

sc1 volumes cannot be used as bootable root volume.

An sc1 volume size can range between 500 GB to 16 TB.

An sc1 volume can have a maximum of 250 IOPS per volumes.

If you use multiple sc1 volumes in an instance, AWS imposes a limit of a maximum of 65000 IOPS per instance.

Root Device Types:

While choosing an AMI, it is essential to understand the root device type associated with the AMI

A bootable block device of the EC2 instance is called root device

As EC2 instances are created from an AMI, it is very important to observe the root device type at the AMI

An AMI can have either of two root device types:
Amazon EBS-backed AMI (uses permanent block storage to store data)
Instance store-backed AMI (which uses ephemeral block storage to store data)

While creating an EC2 instance using a web console we can see whether an AMI is EBS or instance-backed

Amazon EBS-backed AMIs launch faster than instance-stored AMIs as you only need to create the volume from the snapshot, for booting the instance.

While AMIs with ephemeral storage take a longer time to boot, as you need to load all the software on the ephemeral storage before booting the instance.

Ephemeral storage devices are directly attached to the host computer, which makes it faster in accessing the data, however, stored data gets wiped out on restarting or shutting down the EC2 instance.

It is very important to remember that EBS-backed instances can be stopped; If ephemeral-based instances are stopped or terminated, the data stored on the ephemeral storage gets wiped out from the storage.

Snapshots

Amazon Elastic Block Storage (or EBS for short) is a service for providing block storage to your EC2 instances. In other words, it provides reliable volumes (hard drives) to your cloud servers.

One very useful function of Amazon EBS is creating an EBS snapshot of your EBS volume. They are nothing but a backup of your EBS volume.

An EBS snapshot is a point-in-time backup of your EBS volume. It is a “copy” of the data on your EBS volume.

If you are looking for a disaster-recovery solution for your EBS volume, this is the solution.

If you want to “backup” your EC2 instance, then you want to create EBS snapshots of the EBS volumes attached to the instance.   EBS snapshots are stored in Amazon S3. However, you are not going to find your snapshots in any of your S3 buckets.

Create AMI from an existing instance:

I hope you got enough ideas on how to create new Linux and Windows instances and ho to connect them. Also, we also saw how to create an image from existing instances. These topics of this chapter are very important from practical and certification purposes.

Please write your comment below for any suggestions and join me in the next chapter.

This Post Has One Comment

Leave a Reply