Introduction to EC2
Neha Sharma
Posted on September 11, 2022
As a beginner in the AWS world, you would hear a lot about EC2.
In this blog, I will try to explain to you what is EC2 and its concepts of it.
Here is the agenda
- What is compute
- What is EC2
- EC2 components
- AMI
- instance family
- Instance purchasing options
- Tenancy
- User Data
- Storage options
- Security
What is compute?
Compute is like a brain. It takes care of the computing or processing tasks. In a simple language, think to compute what RAMs and CPUs do but in the cloud. In a cloud world, computing is an important service.
There are different compute services based on the requirement:
Long-running compute operations: EC2
On-demand compute operations: Lambda (serverless)
What is EC2?
EC2 is one of the AWS computing services. Known as Elastic compute cloud. It allows for the deployment of virtual systems. This is widely used for applications which required long-running processing, and execution. EC2 service is powerful, and you will keep encountering EC2 while working on cloud solutions.
EC2 gets billed per second. It is important to terminate the instance once it is not in the use.
EC2 can be broken into important concepts:
- AMI (Amazon Machine Image)
- Instance Types
- Instance purchasing options
- Tenancy
- User Data
- Storage options
- Security
AMI (Amazon Machine Image)
AMI templates of pre-configured EC2 instances are ready to launch based on the configuration of AMI. Think of them like base images you can choose the base operating system and applications along with custom configurations. This prevents you from installing the OS and other applications.
One can customise the AMIs and as well as there is an AWS marketplace to purchase from non-AWS vendors.
Choosing and configuring an AMI is the first step of the EC2 creation.
Instance Family
An instance can be of one type from the below list. The type of instance is based on the usage. The cost will vary based on the instance type
- Micro instances
- General-purpose
- Compute optimised
- GPU
- FPGA
- Memory optimised
- Storage optimised
User Data
While configuring EC2, there is a section called 'user data' where devs can enter the commands that will run first time at the boot of the EC2. This is helpful if we want any application to be installed, or updated.
Tenancy
A tenancy is related to the host on which our EC2 will reside. There are 2 types of hosts:
- Shared
Host (tenancy) will be shared by others also but AWS takes the security seriously. So, your application, and data would not be accessible by anyone else and vice versa.
- Dedicated
Here as the name suggests, it is the dedicated host where only your application will reside on the dedicated host.
Purchasing options
One can purchase the EC2 instance types. There are different payment plans and there are helpful to save us the cost.
1. On-demand instance
-
Can be launched anytime, and provision and available within minutes
- Can be used for short or as long as you need before terminating it. Once you terminate the instance you will stop paying for it.
- These instance has a flat rate and are billed in seconds.
- These instances should be used for short-term or interrupted work. The most common use of such instances is the test environment.
2. Reserved instance
These are the instance which gives a 75% price reduction in comparison to the on-demand instance.
One needs to reserve the instances for a timeframe from 1 to 3 years.
-
One can save a lot based on which payment plan it will use:
a) upfront: in this, all payment is made for reservation of 1-3 years and received the maximum discountb) partial payment: in this only the partial payment is done and the discount has lesser than the upfront.
c) no-upfront: in this, no payment is made and receive no discount
Reserved instances are used for long-term predictable workloads allowing you to make full use of the cost savings to be had when using compute resources offered by EC2.
3. Scheduled instance
this is just like the reserved instances but the difference here is we reserved for the scheduled time such as day, week, or monthly.
it is used where you have a task which is scheduled to be run daily, weekly, or monthly.
this helps in saving money as with on-demand or reserved you will be paying even when you are not using them with scheduled you can schedule instances when the task is scheduled
4. Spot instance
Here you can bid for the unused instances.
higher the bid and you will get the instances
but once someone else bid will go higher your instance will be terminated after giving you 2 min warning.
good for interrupted tasks.
5. Capacity reservations
Allows you to reserve the capacity based on the different attributes such as instance type, platform, etc.
This reservation will happen for a particular availability zone
This helps in making the instances available and ready for use.
Storage options
1. Persistent
Persistent storage is persistent storage. Think of them as external storage devices such as hard disks we use with our system to save data.
2. Ephemeral
Ephemeral storage or instance-backed storage is the storage that is physically attached to the underlying host on which the EC2 instance resides. This storage is not permanent. Once the EC2 will be rebooted the data would be lost.
Security
Security is an important area of the cloud. Security groups control communication to your instance. It is a Kind of firewall for your instance. Controlling egress, and ingress traffic. You can restrict this communication by source ports and protocols for both inbound and outbound communication
Happy Learning!!
Posted on September 11, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.