Tags Archives: ec2

AWS EC2 Elastic Cloud Compute

EC2 or Elastic Cloud Compute is the most popular AWS service.

 

EC2 consists of

 

Renting virtual machines (EC2s)

 

Storing data on virtual drives (EBS or Elastic Block Storage)

 

Distributing load across machines (ELB or Elastic Load Balancer)

 

Scaling EC2 services by using an auto-scaling group or ASG

 

 

EC2 Provisioning Considerations

 

You select an EC2 Instance Type, which specifies:

 

CPU power and cores

 

OS to deploy

 

RAM

 

Storage space

 

– network attached eg EBS & EFS

 

– hardware attached ie EC2 Instance Store

 

Networking – speed of interface, public IP, subnet/s

 

 

Firewalling rules – security group

 

Bootstrap script for first bootup – “EC2 User Data” script – can do almost anything – eg update software, download files, configure or copy config or data files etc

 

 

NOTE the user data script runs with sudo root user.

 

 

Choosing an AWS Region

 

You will usually want to choose a region closest to your customers or users.

 

For price comparisons for AWS regions see  https://instances.vantage.sh/ for precise info about ec2 options

 

and the AWS https://calculator.aws/#/

 

and https://www.instance-pricing.com/provider=aws-ec2/cheapest/ for cheapest regions

 

ap-south-1 Mumbai is cheap

 

Virginia, Ohio, Oregon and Mumbai are often the cheapest,  London and Frankfurt more expensive. 

 

N. Virginia is typically the cheapest region.

 

If you want to have the cheapest prices, best selection of products and highest number of Availability Zones, then N. Virginia tends to be best. This region is followed closely by Ireland, Oregon and Ohio.

 

Choosing any region outside of N. Virginia, Ireland, Oregon or Ohio means you could end up with only 2 AZs, probably pay more and may have to wait several weeks – even months – before new services are implemented in those regions.

 

 

EC2 Instance Type Naming Convention

 

example:

 

m5.2large

 

m = instance class
5 = hardware generation – improves over time
2xlarge = size within the instance class

 

price will obviously vary according to instance type.

 

 

 

Quick Overview of Instance Types 

 

General purpose:  A1, T3, T3a, T2, M6g, M5, M5a, M5n, M4

 

Compute optimized:  C5, C5n, C4

 

Memory optimized:  R5, R5a, R5n, X1e, X1, High Memory, z1d

 

Accelerated computing:  P3, P2, Inf1, G4, G3, F1

 

Storage optimized:  I3, I3en, D2, H1

 

 

Amazon EC2 Instance Types In More Detail 

 

M and T families: General purpose

 

The M and T families are the main EC2 instance types.

 

M family provides a good mix of CPU, RAM, plus disk size/performance,. M serves as a good choice for applications that have consistent performance requirements.

 

Generally, you can start with an M instance and then monitor performance. If the instance turns out to be inadequate for your performance needs, then you can switch over later to another family.

 

The T family is a low-cost alternative to the M family. It accommodates general-purpose workloads but is also burstable.

 

T instances are intended to operate at a lower level of basic performance but they also provide a form of built-in elasticity in being able to automatically burst performance as required.

 

They are especially useful for lower-throughput applications such as admin applications, low-traffic websites, or testing and development projects.

 

 

C family: Compute-optimized

 

C instances are designed for applications that require large amounts of computing power, using high ratios of vCPUs to RAM, but also offering the lowest cost per vCPU.

 

For example: on-demand batch processing activities, video encoding tasks, and high-performance science and engineering-based applications as well as front-end fleets that run high-traffic websites.

 

 

X, R, z1d, and High Memory families: Memory-optimized

 

The memory-optimized instance families offer the most RAM of all EC2 instance types and are primarily designed for running large in-memory databases. They range from 3TB to 24TB RAM

 

The X1, X2, R4, R5, R6, and z1d instances are especially designed for memory-intensive applications. These families also offer the lowest cost per GB of RAM, which makes them an ideal choice for applications that are heavy users of RAM.

 

The R families are well-suited to big-data processing in real-time, data mining, and Hadoop or Spark clusters.

 

X1 and X2 instances are ideal for enterprise-sized in-memory applications, such as SAP HANA which require greater RAM than the R family.

 

z1d instances offer high single-thread performance with a sustained all-core frequency of up to 4.0 GHz. This makes them the fastest of all AWS EC2 instances, providing both high-compute performances combined with high memory.

 

z1d is especially suited to tasks such as  electronic design automation or EDA, gaming, or relational database workloads which have high per-core licensing costs.

 

 

H, D, and I families: Storage-optimized

 

H, D, and I families provide high performance combined with local storage. This is in contrast to most other instance families, such as the compute-optimized and general-purpose instance types, which rely solely on attached EBS volumes rather than their own local storage.

 

They offer a wide range of storage sizes, either with HDDs or SSDs. H1 offers up to 16TB of hard drive storage.

 

H family is well-suited to workloads that use MapReduce or streaming operations such as Apache Kafka.

 

D3 provides up to 48TB of hard drive storage. Use cases for D3 include massively parallel processing data warehousing, Hadoop, and distributed file systems.

 

I3 instances include Non-Volatile Memory Express (NVMe) SSD-based instance storage. The I family provides low latency with high sequential read throughputs and very high random I/O performance, which makes I3 ideal for hosting in-memory databases,  NoSQL databases, data warehousing, running Elasticsearch, as well as analytics workloads.

 

P and G families: Accelerated computing

 

P and G instance families offer a combination of high performance and cost efficiency and are ideal for graphics-processing-intensive  and machine-learning applications.

 

P instances are suitable for general-purpose GPU applications such as video editing.

 

G instances are specifically designed for running GPU-heavy applications, such as automated speech recognition or language translation processes.

 

 

 

Securing Your EC2 Instance

 

 

You are responsible for configuring appropriate and effective access controls to protect your EC2 instances from unauthorized use.

 

Broadly speaking, AWS provides four tools to help you with this task:

 

security groups

 

Identity and Access Management (IAM) roles

 

network address translation (NAT) instances

 

key pairs.

 

 

 

EC2 Hibernate

 

 

You set hibernation in the EC2 Dashboard for the instance. 

 

Then to activate hibernation click on “Instance State” -> hibernate 

 

 

We have following options for EC2 Instances

 

Stop: data on EBS is kept intact for next start

 

Terminate: data on EBS is destroyed

 

First Start: OS boots, EC2 user data script runs

 

Subsequent Starts: OS boots

 

This however takes time…

 

With Hibernate however,

 

RAM in-memory state is preserved and boot is faster – OS state is frozen

 

this is written to a file in EBS volume -must have sufficient space and root

EBS volume must be encrypted. RAM is dumped to EBS.

 

Use cases:

 

for long running processes you dont want to interrupt or stop

 

saving the RAM state

 

services that take long time to initialize and start

 

limitations:

 

RAM must be under 150GB

 

not available for bare metal instances

 

must be Linux or Windows os

 

AND – cannot be hibernated for more than 60 days!

 

 

 

 

EC2 Nitro 

 

This is a new virtualization tech for EC2 for the future.

 

offers
better networking options
high performance computing
ipv6 support
higher speed EBS volumes supported
better security

 

types using Nitro: C5+, D G, M, instance types.
plus bare metal al.metal, c5.metal etc

 

vCPU

 

multiple threads can run on 1 CPU. multithreading

 

each thread is called vCPU in AWS

 

eg m5.2xlarge

 

is 4 CPU
2 threads per CPU
which makes 8 vCPU

 

the vCPU value does not specifiy the thread and CPU combination!

 

but in some cases you may want to decrease the number of vCPUs on your instance

 

eg to create more RAM and lower CPUs for software licensing costs

 

to change number of threads per core: you can disable multithreading which will mean 1 thread per CPU, which is helpful for hpc computing workloads

 

 

EC2 Capacity Reservations

 

ensure you have sufficient capacity available when needed-

 

it is a short term reservation

 

immediate reservation, billing starts immediately on reservation

 

you specify instance type, which AZ – only 1 AZ per reservation,  if you want eg 3 AZs then you need to specify 3 reservations.

 

you can combine with reserved instances and savings plans to cut cost.

 

 

AMI Amazon Machine Image

 

 

AMI is a customization of an EC2 instance

 

you add your own software, config, os, etc

 

faster boot/config because all the software is prepackaged

 

can be built for a specific region and can be copied across regions

 

you can launch EC2 instances from

 

a public AMI -provided by AWS

 

and we can also create our own AMIs but you have to make and maintain them yourself

 

or you can purchase AMIs in the AWS Marketplace made by others

 

you can also sell AMIs yourself in the marketplace

 

The AMI Process from an EC2 perspective

basically

 

we start an EC2 instance and customize it

 

then stop the instance – to ensure data integrity

 

we create an AMI of the instance – and this also creates EBS snapshots

 

we launch instances from our AMI

 

 

so, in detail:

 

 

create an EC2 instance, select type, network etc, add storage, some advanced details, including user data script.

 

then you create the AMI image using the EC2 dashboard, this takes a little time then it will be listed under ami images.

 

you can then use the image to create additional new EC2s – ie it serves as a full template instance.

 

 

 

 

 

 

 

 

 

 

Continue Reading