Published: Feb 03, 2023
Amazon Elastic Compute Cloud (Amazon EC2) is a service that provides scalable cloud capacity in the Amazon Web Services (AWS) cloud. With Amazon EC2, organizations can choose between a wide variety of instances that are optimized for different cloud computing use cases. In this tutorial, we’ll explain everything you need to know about the different EC2 instance types and their pricing model.
With AWS EC2, you can choose between different instance types and scale up and down the resources (CPU, memory, storage, networking capacity, etc.) you need to run your applications in the cloud. With AWS EC2, you’ll just need to pay for the time you use your instances.
AWS EC2 instances are secure as you’ll connect to them using SSH keys. You can create or launch your instance using the AWS Command Line Interface or the AWS Management Console. Moreover, you can view all your EC2 instances in the AWS Management Console.
For organizations, using AWS EC2 instances for their various cloud computing needs offers various advantages. Here are the main benefits you should know about:
When you create an AWS EC2 instance, you’ll need to choose your instance type. Each type offers different hardware, computing, memory, and storage capabilities
General purpose instances provide a balanced set of computing power, memory, and networking resources. They are suitable for small to medium-sized databases, backend servers, gaming servers etc.
Compute-optimized instances are tailored for applications that require high-performance processors. They are mostly used to perform batch processing workloads, scientific modeling, machine learning, and other compute-intensive applications.
Memory-optimized instances are designed to provide fast performance for workloads involving large databases. They’re mostly used by organizations working with high-performance MySQL, NoSQL, or MongoDB databases, but they’re also well-suited for the real-time processing of big data.
Accelerated computing instances use hardware accelerators to perform functions such as floating point number calculations, graphics processing, or data pattern matching.
Storage-optimized instances are used for workloads that require high read and write access to very large data. These instances are well suited for data processing applications and Redis, an in-memory data structure store that can be used for databases.
As we’ve seen previously, AWS EC2 instances come with various configurations of CPU, memory, storage, and networking capacity. EC2 instances are launched in virtual computing environments, and Amazon provides preconfigured templates that contain the operating system and other software required to run them.
An Amazon Machine Image (AMI) is a template that is used to launch an instance. It contains the operating system, system configurations, an application server, and applications, and launch permissions that control which AWS accounts can use the AMI to launch instances.
You can manage Amazon EC2 instances with one of the following operating systems:
In some cases, an instance can be provisioned with excess CPU and memory capabilities. As a result, customers may pay for more resources than what they really use.
Burstable performance instances are optimized for applications that have low-to-moderate CPU usage. They offer a baseline CPU performance, but organizations can still burst above the baseline when their workload requirements change.
These instances are suitable for large-scale micro-services, web servers, small and medium databases, data logging, code repositories, virtual desktops, and development and test environments. Amazon claims that customers can save up to 15% in costs compared to using regular instances.
When launched, AWS EC2 instances need storage space. Below are some of the storage options that are available to be used with AWS EC2:
When you launch an Amazon EC2 instance, it’s assigned a private IP address by default, and a public IP address can also optionally be allocated to it. However, when an instance is restarted, then both the private and public addresses are changed.
If you need a static IP for your instance, then you should use an Elastic IP address. It is a static and public IPv4 address, meaning it’s accessible from the internet. If your instance doesn’t have a public IPv4 address, you can associate an Elastic IP address to it to enable communication with the Internet.
Automated Scaling is an important feature that adjusts the capacity of all your instances to maintain a predictable performance for all applications at the lowest possible cost.
With Auto Scaling, it’s easy to set up application scaling for multiple resources across multiple services in minutes. Auto Scaling can be enabled with the AWS Management Console, the AWS Command Line Interface (CLI), or the AWS SDK, and it’s available at no additional charge.
An Amazon EC2 instance goes through different states from the moment you launch it to its termination. When you initially launch an EC2 instance, it first goes into a pending state before it reaches its running state.
Your instance will also go into a pending state again if you stop it, or when it’s being restarted. When the instance is transitioning from a pending state to a running state, it is not billed at all. It’s also not billed when it’s preparing to be stopped and once it’s been shut down.
It is very important to monitor your AWS EC2 instances, and you can do it with AWS CloudWatch. This service collects data such as CPU, memory, and more, and it makes it easily accessible in automated dashboards. By default, Amazon EC2 sends metric data to CloudWatch in 5-minute periods.
It’s your choice to enable AWS CloudWatch monitoring or not. However, there are no charges involved in monitoring your AWS EC2 instances.
Some of the crucial instance metrics that should be monitored include:
Yes, you can change the type of an AWS EC2 instance depending on your needs. You can easily identify if the instance is overloaded by monitoring the CPU and memory utilization of the instance, then you can downgrade it anytime if necessary.
On the other hand, if your t2.micro instance is too small for its workload, you can increase its size by changing it to a bigger T2 instance type, such as t2.large.
There are multiple ways to pay for Amazon EC2 instances, but you can also get started with the AWS Free tier. Let’s take a look at all the possibilities at your disposal.
The AWS Free tier lets you access AWS services for 12 months free of charge. You can use an AWS EC2 instance with the AWS Free subscription under the following conditions:
There is no long-term commitment when you use on-demand instances, so you just need to pay your usage per second or per hour with a minimum period of 60 seconds. On-demand instances are mainly used for short-term, irregular workloads that can be interrupted. They’re more costly than Spot instances, which we’ll detail right after.
If you require to launch your instance very quickly, then you can use Spot instances, which let you request unused EC2 instances at very high discounts. Spot instances can be up to 90% cheaper than on-demand instances, though they’re mainly used for quick data analysis, batch jobs, and background processing.
With Savings plans, organizations can take advantage of a more flexible pricing model with low prices on EC2 and Fargate usage. However, customers need to use these instances for a one- or three-year term.
A Dedicated host is a physical EC2 server with a capacity that is fully dedicated to your use. Dedicated hosts can be purchased on-demand (hourly), and you can save money by using your own software licenses, including Windows Server, Microsoft SQL Server, SUSE, and Linux Enterprise Server.
Overall, AWS EC2 provides a very wide range of instance types with a large choice of processors, storage, networking, and operating systems. Amazon also offers different pricing models allowing organizations to choose the instance type that fits the needs of their workloads. We hope that after reading this overview you’ll be ready to get started with your first EC2 instance in the AWS cloud.