AWS EC2: Understanding for the beginners

Explains the basics of AWS EC2 instances


Understanding AWS-EC2

This blog aims at attemp to understand the basics of AWS EC2 and differentiate the features, instance types, and pricing used by Amazon EC2. Amazon EC2 offers over 500 instance types. You can choose the latest processor, storage, networking, and operating system to help you match the needs of your workload [1].

Instance types

An EC2 instance is a virtual machine (VM) that runs in the AWS Cloud. When you launch an instance, you decide the virtual hardware configuration by choosing an instance type. The instance type that you choose determines the hardware of the host computer used for your instance. Each instance type offers different compute, memory, and storage capabilities, and is grouped into an instance family based on these capabilities.

  • An instance is a VM.
  • An instance type is the combination of virtual hardware components, such as CPU and memory, that make up the instance.
  • Instance types are grouped together into instance families. Each instance family is optimized for specific types of use cases.
  • Instance families have sub-families, which are grouped according to the combination of processer and storage used.
  • A virtual central processing unit (vCPU) is a measure of processing ability. For most instance types, a vCPU represents one thread of the underling physical CPU core. For example, if an instance type has two CPU cores and two threads per core, it will have four vCPUs.

Instance Families

The AWS instances are currently categorized into five distinct families. To learn more, expand each of the following five categories [2].

  • General purpose : General purpose instances provide a balance of compute, memory, and networking resources and can be used for a wide range of workloads. These instances are ideal for applications that use these resources in equal proportions, such as web servers and code repositories.
    • Burstable instance options: Many workloads are not busy all the time and do not require sustained CPU performance. Using a large instance for these low-to-moderate workloads leads to waste and unnecessary cost. For these workloads you can take advantage of the low-cost burstable general purpose instances, which are the T family instances. A burst is when the activity on the instance exceeds normal operation for a short period; for example, when the workload temporarily spikes. The T instance family provides a baseline CPU performance with the ability to burst above the baseline at any time for as long as required. The T instances offer a balance of compute, memory, and network resources. They provide you with the most cost-effective way to run a broad spectrum of general purpose applications that have a low-to-moderate CPU usage.
  • Compute optimized: Compute optimized instances are ideal for compute-bound applications that benefit from high-performance processors. Instances belonging to this family are well suited for compute-intensive operations, such as the following: Batch processing workloads, Media transcoding, High performance web servers, High performance computing (HPC), Scientific modeling, Dedicated gaming servers and ad server engines, Machine learning (ML) inference.
  • Memory optimized: Memory optimized instances are designed to deliver fast performance for workloads that process large data sets in memory.
  • Storage optimized: Storage optimized instances are designed for workloads that require high, sequential read and write access to very large data sets on local storage. They are optimized to deliver tens of thousands of low-latency, random input/output (I/O) operations per second (IOPS) to applications.
  • Accelerated computing: Accelerated computing instances use hardware accelerators, or co-processors, to perform some functions more efficiently than is possible in software running on CPUs. Examples of such functions include floating point number calculations, graphics processing, and data pattern matching. Accelerated computing instances facilitate more parallelism for higher throughput on compute-intensive workloads. If you require high processing capability, you will benefit from using accelerated computing instances, which provide access to hardware-based compute accelerators such as graphics processing units (GPUs), field programmable gate arrays (FPGAs), or AWS Inferentia.

The bottom image briefly summarizes different families[3].

aws-ec2-instance-fammilies

Understanding Instance Family Names

For example, we have an instance name: m5zn.xlarge.

  • Instance Family: The first letter represents the instance family. For example, M represents a general purpose instance sub-family.
  • Instance Generation: This number represents the generation of the processor, with higher number being the latest and newest generation. The newest generation often provides a performance improvement, a cost saving or both.
  • Attribute: This is optional but when provided it indicates about instance capabilities. For example, Z indicates high frequency. Additional possibilities are listed below:
    • a: AMD processor
    • g: AWS Graviton processors
    • i: intel processors
    • d: instance store volumes
    • n: Network optimization
    • b: Block storage optimization
    • e: Extra storage or memory
    • z: High frequency
  • Another-Attribute: This an another optional attribute and indicates what the instance is optimized to. For example, z stands for high frequency while n stands for network. Together they indicates that this instance is high performance instance for workloads such as gaming and HPC.
  • Size: This represents size of the instance. The larger the size, the more resources such as CPUs and memory. EC2 instances are sized based on the combined hardware resources consumed by that instance type. This means the size is the total configured capacity of vCPU, memory, storage, and networking. The sizes range from nano to upwards of 32xlarge, with a nano-sized instance using the least amount of hardware resources and the 32xlarge instance using the most amount of hardware resources (128 vCPU and 1,024 GiB memory).

Right-Sizing

Right-sizing is the process of matching the resource types and sizes to your workload requirements. It’s also the process of looking at deployed instances and identifying opportunities to eliminate or downsize without compromising capacity or other requirements. Imagine you are grocery shopping. If you buy too much food, it will go to waste. If you buy too little food, you will go hungry. You want the right amount to suit your needs, no more, no less. Right-sizing is a key mechanism for optimizing AWS costs, but it is often ignored by organizations when they first move to the AWS Cloud. Many organizations rebuild their identical on-premises servers in the cloud and plan to go back and right-size later. Oftentimes, speed and performance are prioritized over cost, which results in oversized, underused instances and a lot of money spent on unused resources.

Advantages of Cloud Computing

  • Economics of Scale: By using cloud computing, you can achieve a lower variable cost than you can get on your own. Because usage from hundreds of thousands of customers is aggregated in the cloud, providers such as AWS can achieve higher economies of scale, which translates into lower pay-as-you-go prices.
  • Variable Capacity: Eliminate guessing on your infrastructure capacity needs. When you make a capacity decision before deploying an application, you often end up either sitting on expensive idle resources or dealing with limited capacity. With cloud computing resources, such as Amazon EC2, these problems can go away. You can access as much or as little capacity as you need, and you can configure your environment to automatically scale up and down as needed.
  • Increased Speed and Agility: In a cloud computing environment, new IT resources are only a click away, which means that you can reduce the time to make those resources available to your developers from weeks to just minutes. This results in a dramatic increase in agility for the organization, because the cost and time it takes to experiment and develop is significantly lower.
  • No need to steup and maintain data centers: Focus on projects that differentiate your business, not the infrastructure. With cloud computing, you can focus on your own customers, rather than on the heavy lifting of racking, stacking, and powering servers.
  • Trade fixed expense for variable expense: Instead of having to invest heavily in data centers and servers before you know how you’re going to use them, you can pay only when you consume computing resources and pay only for how much you consume.
  • Go Global in minutes: Deploy your application in multiple ÀWS Regions around the world with just a few clicks. This means that you can provide lower latency and a better experience for your customers at minimal cost.

At a fundamental level, there are three types of compute options: virtual machines, container services, and serverless. A virtual machine emulates a physical server and allows you to install an HTTP server to run your applications. To run these virtual machines, you install a hypervisor on a host machine. This hypervisor provisions the resources to create and run your virtual machines.In AWS, these virtual machines are called Amazon Elastic Compute Cloud or Amazon EC2. Behind the scenes, AWS operates and manages the host machines and the hypervisor layer. AWS also installs the virtual machine operating system, called the guest operating system.Some AWS compute services use Amazon EC2 or use virtualization concepts under the hood

Pricing model for AWS EC2

following are the six major categories for pricing models:

On Demand

With On-Demand Instances, the customer pay for compute capacity by the hour or the second, depending on which instances are run. No longer-term commitments or upfront payments are needed. Customer can increase or decrease your compute capacity depending on the demands of his application, and he only pay the specified hourly rates for the instance that he uses. Following are the recommendations for the On-Demand Instances for the following situations:

  • Users that prefer the low cost and flexibility of Amazon EC2 without any up-front payment or long-term commitment.
  • Applications with short-term, spiky, or unpredictable workloads that cannot be interrupted.
  • Applications being developed or tested on Amazon EC2 for the first time.

Spot

With Amazon EC2 Spot Instances, you can request spare Amazon EC2 computing capacity for up to 90 percent off the On-Demand price. Following are the recommendations for the Spot Instances for the following situations:

  • Applications that have flexible start and end times and can tolerate interruptions.
  • Applications that you want to run or test only when the compute prices are in your price range.
  • Applications that are a lower priority in your environment.
  • Users with urgent computing needs for large amounts of additional capacity at a price they determine.

Saving Plans

Savings Plans is a flexible pricing model offering lower prices compared to On-Demand pricing, in exchange for a specific usage commitment (measured in USD per hour) for a 1– or 3–year period. Savings Plans offers the flexibility to evolve your usage and continue to save money. For example, if you have a Compute Savings Plan, lower prices will apply automatically when you take advantage of new instance types. AWS offers three types of Savings Plans:

  • Compute Savings Plans apply to usage across Amazon EC2, AWS Lambda, and AWS Fargate.
  • EC2 Instance Savings Plans apply to Amazon EC2 usage.
  • Amazon SageMaker Savings Plans apply to SageMaker usage.

Reserved Instances

Amazon EC2 Reserved Instances, sometimes referred to as RIs, provide a significant discount (up to 72 percent) compared to On-Demand pricing and provide a capacity reservation when used in a specific Availability Zone. Reserved Instances are not physical instances, but rather a billing discount applied to the use of On-Demand Instances in user's account. There are two types of Reserved Instances to choose from:

  • Standard: These provide the most significant discount (up to 72 percent off On Demand) and are best suited for steady-state usage.
  • Convertible: These provide a discount (up to 54 percent off On Demand) and the capability to change instance families, operating system types, and tenancies while benefitting from Reserved Instance pricing when you use the Convertible type. As with the Standard type, Convertible Reserved Instances are best suited for steady-state usage.

Following are the recommendations for the Reserved Instances for the following situations:

  • Steady-state loads and long running systems.
  • Core components with minimal high peaks or valleys of usage.

Saving Plans compared with Reserved Plans

Savings Plans offer the following:

  • The ability to switch Regions:
  • A plan that automatically adapts itself to change in instances.
  • Lower prices on EC2 instances usage, regardless of instance family, size, operating system, tenancy or Region. This also applies to Fargate and Lambda usage.

Two types of Saving Plans relate to Amazon EC2:

  • EC2 Instance Saving Plans: These provide the lowest prices in exchange for commitment to usage of individual instance families in a Region (for example, M5 usage in US East (N. Virginia)). This automatically reduces your cost on the selected instance family in that Region regardless of Availability Zone, size, operating system, or tenancy. EC2 Instance Savings Plans give you the flexibility to change your usage between instances within a family in that Region. For example, you can move from c5.xlarge running Windows to c5.2xlarge running Linux and automatically benefit from the Savings Plans prices.
  • Compute Saving Plans: These plans automatically apply to EC2 instance usage regardless of instance family, size, Availability Zone, Region, operating system, or tenancy, and also apply to Fargate and Lambda usage.

For Reserved Instances consider the following:

  • The price is fixed over the 1- or 3-year commitment period.
  • You are limited to one Region or one Availability Zone.
  • Coverage is broader and includes Amazon Relational Database Services (Amazon RDS).
  • You pay for the entire term of a Reserved Instance, regardless of actual usage, so your cost savings are closely tied to use.
  • When you purchase a Reserved Instance in a specific Availability Zone, it provides a capacity reservation.
  • You can sell additional capacity on the Reserved Instances marketplace. However, this requires additional monitoring and management overhead.

Dedicated Hosts

A Dedicated Host is a physical Amazon EC2 server dedicated for your use. Dedicated Hosts can help you reduce costs by permitting you to use your existing server-bound software licenses, including Windows Server, Microsoft SQL Server, and SUSE Linux Enterprise Server (subject to your license terms) and can also help you meet compliance requirements.

Dedicated Hosts can be purchased in two ways:

  • On Demand (hourly):
  • As a Reservation, for up to 70 percent off the On-Demand price

We recommend Dedicated Hosts for the following situations:

  • Workloads that require server-bound software licenses
  • Security and regulatory compliance cases, where your workload cannot share hardware with other tenants.

Summarizing

  • On-Demand Instances – You pay full price, by the second when you launch.
  • Spot Instances – This refers to unused instance resources that you can bid on. Your price is determined by market availability. Spot Instances are useful for short workloads and workloads that are built to handle interruptions.
  • Reserved Instances – You agree to a specific instance configuration for a period of 1–3 years. Standard Reserved Instance are usefuk for steady-state applications.
  • Dedicated Hosts – You get a full physical server.
  • Savings Plans – You commit to a certain amount of usage over a 1–3-year period. [4]

Useful tools

These useful tools give insights into instance usage. They provide an indepth analysis and recommendations related to cost saving and instance utilizations. Following are the tools:

AWS Compute Optimizer

AWS Compute Optimizer is a right-sizing recommendation tool that you can use to improve your AWS infrastructure efficiency. Compute Optimizer analyzes the configuration and utilization metrics of your current resources and then generates recommendations for more optimal configurations by considering both cost and performance. It evaluates your resources using your default Amazon CloudWatch metrics to analyze usage patterns from data acquired over the previous 14 days. The service has no additional charge by default.

By applying knowledge gathered from business experience that Amazon itself has gained in running diverse workloads in the cloud, Compute Optimizer identifies workload patterns and recommends optimal AWS resources. Compute Optimizer analyzes your workload to identify dozens of defining characteristics, such as, if it is CPU intensive, if it exhibits a daily pattern, or if a workload accesses local storage frequently.

The service processes these characteristics and identifies the hardware resource required by the workload. Compute Optimizer then infers how the workload would have performed on various hardware platforms (for example, EC2 instance types) or using different configurations to offer recommendations.

Compute Optimizer classifies its findings for EC2 instances into four categories:

  • Under-provisioned: An EC2 instance is considered under-provisioned when at least one specification of your instance, such as CPU, memory, or network, does not meet the performance requirements of your workload. Under-provisioned EC2 instances might lead to poor application performance.
  • Over-provisioned: An EC2 instance is considered over-provisioned when at least one specification of your instance, such as CPU, memory, or network, can be sized down while still meeting the performance requirements of your workload, and when no specification is under-provisioned. Over-provisioned EC2 instances might lead to unnecessary infrastructure cost.
  • Optimized: An EC2 instance is considered optimized when all specifications of your instance, such as CPU, memory, and network, meet the performance requirements of your workload, and the instance is not over-provisioned. An optimized EC2 instance runs your workloads with optimal performance and infrastructure cost. For optimized instances, Compute Optimizer might sometimes recommend a new generation instance type.
  • None: There are no recommendations for this instance. This might occur if you've been opted in to Compute Optimizer for less than 12 hours, or when the instance has been running for less than 30 hours, or when the instance type is not supported by Compute Optimizer.

AWS Pricing calculator

AWS Pricing Calculator is a web-based planning tool that you can use to create estimates for your AWS use cases. You can use it to model your solutions before building them, explore the AWS service price points, and review the calculations behind your estimates. You can use it to help you plan how you spend, find cost saving opportunities, and make informed decisions when using AWS.

AWS Pricing Calculator is useful for those who have never used AWS. It's also useful for those who want to reorganize or expand their AWS usage. You don't need any experience with the cloud or AWS to use AWS Pricing Calculator.

With AWS Pricing Calculator, you can do the following tasks:

  • View transparent prices: View the calculations behind the estimated prices for your service configurations. You can view price estimates by service or by groups of services to analyze your architecture costs.
  • Use groups for hierarchical estimates: Sort your estimates into groups to align with your architecture for clear service cost analysis.
  • Share your estimates: Save the link to each estimate to share or revisit at a later time. Estimates are saved to the AWS public servers.
  • Export your estimated: Export your estimates in comma-separated values (CSV) or portable document format (PDF) files to share locally with your stakeholders.

AWS Cost Explorer

You can use AWS Cost Explorer to view and analyze your costs and usage. You can view data for up to the last 12 months, forecast how much you're likely to spend for the next 12 months, and get recommendations for what Reserved Instances to purchase. You can use Cost Explorer to identify areas that need further investigation and view trends that you can use to understand your costs.

You can view your costs and usage using the Cost Explorer user interface (UI) at no additional cost. Cost Explorer provides preconfigured views that display at-a-glance information about your cost trends and gives you a head start on customizing views that suit your needs.

The right-sizing recommendations feature in Cost Explorer helps you identify cost-saving opportunities by downsizing or terminating instances in Amazon EC2. Right-sizing recommendations analyze your Amazon EC2 resources and usage to show opportunities for how you can lower your spending. You can see all of your underused EC2 instances across member accounts in a single view to immediately identify how much you can save. After you identify your recommendations, you can take action on the Amazon EC2 console.

Cost Explorer provides you with a cost and usage reports. You can't modify these reports, but you can use them to create your own custom reports.

  • Daily costs: This shows how much you've spent in the last 6 months, along with how much you're forecasted to spend over the next month.
  • Monthly costs by linked account: This shows your costs for the last 6 months, grouped by linked, or member account. The top five member accounts are shown by themselves, and the rest are grouped into one bar.
  • Monthly costs by service: This shows your costs for the last 6 months, grouped by service. The top five services are shown by themselves, and the rest are grouped into one bar.
  • Monthly EC2 running hours costs and usage: This shows how much you have spent on active Reserved Instances.

Amazon EC2 also provides resources such as images, instances, volumes, and snapshots. When you create your AWS account, a default quota (also referred to a limit) is set on these resources on a per-Region basis. For example, there is a maximum number of instances that you can launch in a single Region. When you launch a new instance in the US West (Oregon) Region, the instance will only launch if you are below your limit for the maximum number of instances in that Region.

The Amazon EC2 console provides limit information for the resources managed by the Amazon EC2 and Amazon Virtual Private Cloud (Amazon VPC) consoles. You can request an increase for many of these limits. Use the limit information that we provide to manage your AWS infrastructure.

Summary

  • EC2 instances are classified into families, based on optimization.
  • There are five instance families optimized for: general purpose, compute, memory, storage, and accelerated computing.
  • When looking at an instance name, such as c6.small, the first letter is the family, c for compute optimized, the number 6 is the generation of the CPU, and small is the size of the instance.
  • Right-sizing is the process of matching the resource types and sizes to your workload requirements. It’s also the process of looking at deployed instances and identifying opportunities to eliminate or downsize without compromising capacity or other requirements.
  • Picking the optimal instance can help you save cost and ensure your workload has the resources that it needs.
  • If you continually evaluate new instances as they come out, you could experience both improved performance and cost savings.
  • AWS provides various tools to help you to rightsize and optimize your environment, such as Cost Explorer, AWS Health Dashboard, and AWS Pricing Calculator.

[1] https://www.coursera.org/learn/aws-amazon-ec2-basics/home/week/1

[2] https://aws.amazon.com/ec2/instance-types/

[3] https://jaychapel.medium.com/ec2-instance-types-comparison-and-how-to-remember-them-bbb96b578aea

[4] https://aws.amazon.com/ec2/pricing/