This tutorial on AWS EC2 instance will cover approximately all aspects. So, I have decided to keep it in different chapters. In chapter one, we will discuss “What is EC2 Instance“, instance Types, instance pricing and understanding on Spot instances.
I will try to make this tutorial detailed enough so that all your AWS EC2 instance-related queries are answered. Just be patient and read all the chapters of my post.
Let’s start and deep dive –
What is EC2 instance in AWS, EC2 instance types and pricing
How to Launch EC2 instance in AWS and configuration details.
How to SSH to EC2 instance – 3 ways
Before I will tell you about EC2 instance, let’s understand “what is AWS“? AWS (Amazon Web Services) is a cloud provider, who provide servers and services, that you can use on-demand and are scalable. AWS also hosts one of the biggest websites like Amazon.com and Netflix.
In other words, you don’t need to bear hassles of deploying servers or infrastructure on-premise. You can utilize hundreds of services provided by AWS by paying money.
Table of Contents
What is EC2 instance
EC2 (Elastic compute cloud) is Amazon’s one of the most popular offerings. The EC2 instance is a virtual server or machine, you can use to deploy your application. It comes under IAAS (infrastructure as a service). EC2 service capabilities are related to Computing, Storage and Network on rent. Few bullets to support this –
- Virtual machines (EC2) on rent
- Storing data on EBS (Elastic Block Store) virtual drives
- Load distribution across machines using ELB (Elastic load balancing)
- Scaling services using ASG (Auto scale groups)
Benefits of having AWS EC2 instance VS on-premise infrastructure
- Eliminates the need for hardware and Data-center hosting for infrastructure
- Virtual machines are available on-demand to develop and deploy applications fast and easy
- Easily scale up or scale down as per your traffic needs
- Pay for what you use Model – No charge if your EC2 instance or resources are not running.
- Pre-built AMI (Azure machine images) to quickly deploy operating system and applications or software.
- and many more…
EC2 instance Launch types
Below mentioned are the EC2 instance Launch Types –
Are based on the model, “pay for what you use“. As soon as you launch the instance, billing will start every second after the first minute. Best for short workload and pricing is predictable.
- No upfront payment
- Paid for what you use
- No long term commitment
High cost compare to other models
This model is appropriate for those, who have a long term hosting requirements in the cloud. These instances can be reserved, minimum for a year and up to 3 Years. For example, the best use case is long workloads. Reserved EC2 instance model comprises of two more models, Convertible reserved instances and Scheduled reserve instances.
Convertible reserved instances
If you need long term workloads with flexible instance, Then this will be the best option for you. It allows you to change instance size and many other parameters during the term period. Also, provides a discount of up to 45% compared to the on-demand instance.
Scheduled reserve instances
This model allows you to reserve your EC2 instance capacity based on daily, weekly or monthly basis. Also, you have the flexibility to define the time period. For example, if you need an EC2 instance from Monday to Friday (Daily) from 9-5 PM, You are free to reserve in this slot. But this also needs to be reserve minimum for a year.
- Up to 75% discount compared to on-demand instances
- Convertible Flexible instance size
- Recommended for steady-state workloads like Databases
- Can reserve instance size from 1 to 3 years.
- Long term commitments
- Need to pay upfront
Spot instance model is the cheapest but unreliable model in EC2 instance. Why unreliable? Because an instance can be pulled back, whenever the price of spot instance beats your bid price or AWS need resources to be free. The best use case would be short workloads, those who can handle interruptions. For example Batch jobs and data analytics workload.
- Up to 90% discount compared to on-demand instance price
- The most cost-efficient instance in AWS
- Less reliable as you can lose instance any time
- Not great for critical or Database workloads
Spot instances can be a good combo or best utilized when you have Reserved instance for Baseline + on-demand or Spot instance for peak or ad-hoc load.
EC2 Dedicated instances
EC2 instances running on hardware or VPC, which is dedicated to you but that hardware can be shared by other non-dedicated instance in the same account.
- Enables the use of dedicated physical hardware.
- No other customers can share this hardware
- Save up to 70% purchasing dedicated reserved instances
- You don’t have control on instance placement
- Subjected to $2 region fee extra
- The non-dedicated instance can share your hardware in the same account
EC2 Dedicated hosts
In this model, you can launch your EC2 instances on hosts dedicated for you. Also, it gives you additional visibility and control on instance placement. This can be the best use case for companies, that have strong compliance needs.
- Visibility of underlying physical cores/sockets.
- More control on Instance placement
- Very useful for complex licensing model BYOL (Bring your own license)
- Reservation and upfront cost for 3 years.
Dedicated instances VS Dedicated hosts features
EC2 instance types or (EC2 instance sizes)
There are hundred’s of instance types available for EC2 in AWS but I will try to cover important ones. In my view, if you know these instances, then mostly you are covered.
General purpose instances
These instances are widely used for a diverse workload. General purpose instances provide a fine balance for compute, memory and networking. For example, the best use case can be web servers and code repositories.
Instance series starting from A, T and M are General purpose instances. For example, A1.large, T4g.micro, m6g.medium etc.
AWS has a concept of burstable instances a.k.a T2/T3 instances. Burst means, CPU works OK generally with a normal load. But in case of burst (spike) in load, it works better.
AWS provides some free credits with T2/T3 instances to use during a spike if the machine will utilize all credits. CPU will perform badly. When the machine will stop bursting, Credits will again start accumulating. Also, you have the option to buy unlimited burst credits during the EC2 instance launch.
Compute optimized instances
Purpose-built for applications required more CPU or processing power. For example, batch processing, high-performance computing (HPC), Gaming servers or scientific engines.
Series starts with “C” are compute optimized instances in AWS. For example, C6g.large, C5n.metal etc.
Memory optimized instances
Optimized for large workloads which process large datasets in memory. For instance, relational or no SQL databases like MongoDB and Casandra.
Series starting with R,X,u (high memory),z. For example, r6g.medium, r5.8xlarge, u-6tb1.metal etc.
Storage optimized instances
Storage optimized instances are designed for workloads, those are IOPS hungry. These instances are optimized for sequential Read/Write workloads, Random I/O workload and low latency storage for applications. For example, map-reduce or Hadoop distributed computing.
I, D and H are the series for Storage optimized instances. For example i3.xlarge, d2.xlarge, h1.4xlarge etc.
Workloads which require data pattern matching, graphics processing or floating-point number calculations can be hosted with Accelerated computing instances. Because this software can run efficiently in GPU compared to run in CPU.
Series starting with P, G, F and inf1. For example, p3.2xlarge, inf1.xlarge, g4dn.8xlarge.
EC2 instance pricing
Till this point, you must be having a fair idea on EC2 instances. As i have explained earlier, There are 5 ways to pay for EC2 instance.
To do an estimation of your expenses of the EC2 instance. Visit AWS calculator and Add services to know the estimated cost. It helps you to get transparent pricing by showing math behind it. Also, it provides you with the prices of different service across different regions.
How does AWS calculator work?
Check out this self-explanatory diagram, with an illustration.
Lets try to figure out with basic example. I will try to estimate 1 T2.micro instance monthly price in Saving plan and on-demand, to checkout the price difference.
Visit AWS pricing calculator.
Add services (Amazon EC2 instance)
Click on Configure services and Enter details. For example, I will select Asia (Mumbai) as a region and 1 instance of T2.micro with Linux. Let’s quickly estimate monthly price difference in Saving plan and on-demand plan.
Price comparison Saving plan VS On Demand
Saving plan monthly cost (1 year reserve) – USD 5.62 VS On demand price is USD 9.05 without storage.
And with 100GB SSD EC2 monthly price would be USD 17.02 in Saving plan while on-demand is USD 20.45 (monthly).
So you can find out the cost difference. In my view, whenever you plan to host your workload in AWS Cloud. Make sure you have played around and estimated your cost with AWS calculator. This way, you will not get any cost surprises.
I hope, I was able to make you understand about EC2 instance without being complicated. Also, I hope you have enjoyed reading my post.
I wish using AWS pricing calculator, you will be more planned now in terms of cost. And you will not be cursing cloud vendor for unexpected cost in the billing cycle.
Let’s make one more round to revise EC2 instance in easy way.
Easy to learn method for instance – important ones
Series starting with –
R – RAM optimized
C – Compute optimized
M – Medium (RAM and CPU balanced)
I – Storage optimized (I – I/O)
G – Accelerated (G -GPU)
T – Burstable instances
Let me know, Which cloud vendor you find more cost-effective in services? Please share your thoughts in the comment section.
Please visit my next post in this series on ‘How to create and delete EC2 instance“.