AWS : Amazon EC2

AWS : Amazon EC2

What is Amazon EC2 ?

The term "EC2" stands for Elastic Compute Cloud.

Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides secure, resizable compute capacity in the cloud. It is designed to make web-scale cloud computing easier for developers.

Amazon EC2 provides cloud hosted virtual machines, called "instances", to run applications. When you run virtual machines in the cloud environment, they are known as instances.

Instances differ in terms of CPU, RAM (memory), storage, and networking power they offer.

It reduces the time required to obtain and boot new server instances to minutes, allowing you to quickly scale capacity, both up and down, as your computing requirements change.
It changes the economics of computing by allowing you to pay only for capacity that you actually use.

Amazon EC2 provides developers the tools to build failure resilient applications and isolate them from common failure scenarios.

Benefits of EC2 Instance

Some of the benefits of EC2 instance is: -

  1. Flexible Cloud Hosting Services: You have the choice of multiple instance types, operating systems, and software packages. Amazon EC2 allows you to select a configuration of memory, CPU, instance storage, and the boot partition size that is optimal for your choice of operating system and application.

  2. Completely Controlled: You have complete control of your instances including root access and the ability to interact with them. You can stop any instance while retaining the data on the boot partition, and then subsequently restart the same instance using web service APIs.

  3. Elastic Web-Scale Computing: Amazon EC2 enables you to increase or decrease capacity within minutes, not hours or days. You can commission one, hundreds, or even thousands of server instances simultaneously.

  4. Reliable: Amazon EC2 offers a highly reliable environment where replacement instances can be rapidly and predictably commissioned.

  5. Secure: Amazon EC2 works in conjunction with Amazon VPC to provide security and robust networking functionality for your compute resources.

Types of Instances in EC2

Amazon EC2 provides five different types of instances:

  1. General Purpose Instances

  2. Compute Optimized Instances

  3. Memory-Optimized Instances

  4. Storage Optimized Instances

  5. Accelerated Computing Instances

    AWS EC2 Instance - Types & Benefits of Amazon EC2 Explained

General Purpose Instances

The computation, memory, and networking resources in general-purpose instances are balanced. Scenarios, where you can use General Purpose Instances, are gaming servers, small databases, personal projects, etc.

Assume you have an application with a kind of equal computing, memory, and networking resource requirements. Because the program does not require optimization in any particular resource area, you can use a general-purpose instance to execute it.


  • The applications that require computing, storage, networking, server performance, or want something from everything, can utilize general-purpose instances.

  • If high-performance CPUs are not required for your applications, you can go for general-purpose instances.


  • Powered by specifically designed AWS Graviton3 processors.

  • Default optimized with EBS.

  • It consists of dedicated hardware and a lightweight hypervisor.

  • The bandwidth is higher when compared to other types.

Several general-purpose examples from which we can pick: t2.micro, m5 Instance, M6a Instance.

Compute-Optimized Instances

Compute-optimized instances are appropriate for applications that require a lot of computation and help from high-performance CPUs. You may employ compute-optimized instances for workloads including web, application, and gaming servers just like general-purpose instances.

This instance type is best suited for high-performance applications like web servers, Gaming servers.


  • Applications that require high server performance or that employ a machine-learning model will benefit from compute-optimized instances.

  • If you have some batch processing workloads or high-performance computing.


  • Powered by specifically designed AWS Graviton3 processors.

  • It will use DDR5 memory, by which it will get 50% more bandwidth than DDR4.

  • By default EBS optimization.

Compute-optimized instance we can pick: c5d.24large.

Memory-Optimized Instances

Memory-optimized instances are geared for workloads that need huge datasets to be processed in memory.
Memory here defines RAM which allows us to do multiple tasks at a time. Data stored is used to perform the CPU tasks it loads from storage to memory to run. This process of preloading gives the CPU direct access to the computer program.

Assume you have a workload that necessitates the preloading of significant volumes of data prior to executing an application. A high-performance database or a task that requires real-time processing of a significant volume of unstructured data might be involved in this scenario.

In this case, consider using a memory-optimized instance. It is used to run applications that require a lot of memory with high performance.


  • Helpful for databases that need to handle quickly.

  • Processes that do not need a large quantity of data yet require speedy and real-time processing.


  • Elastic Fabric Adapter (EFA) is supported on the r7g.16xlarge and r7g.metal instances.

  • Includes the newest DDR5 memory, which provides 50% more bandwidth than DDR4.

  • Compared to R6g instances, improved networking bandwidth is 20% more.

Several Memory-optimized instances that we can pick : The R and X categories, like R7g.medium, x1.

Storage Optimized Instances

Storage-optimized instances are made for workloads that demand fast, sequential read and write access to huge datasets. Distributed file systems, data warehousing applications, and high-frequency online transaction processing (OLTP) systems are examples of workloads that are suited for storage-optimized instances.

Storage-optimized instances are built to provide applications with the lowest latency while accessing the data.


  • The applications which high processing of databases can utilize storage-optimized instances.

  • Data Warehousing applications or distributed file systems can use it.


  • Using AWS Graviton2 processors, which provide the best price/performance for workloads in Amazon EC2.

  • Geared at tasks that correspond to 4 GB of RAM per vCPU.

  • Improved Networking (ENA)-based Elastic Network Adapter (ENA)-based up to 100 Gbps of network bandwidth.

Storage-optimized instances which we can pick is: Im4gn.

Accelerated Computing Instances

Coprocessors are used in accelerated computing instances to execute specific operations more effectively than software running on CPUs. Floating-point numeric computations, graphics processing, and data pattern matching are examples of these functions.

A Hardware-Accelerator/Co-processor is a component in computing that may speed up data processing. Graphics applications, game streaming, and application streaming are all good candidates for accelerated computing instances.


  • If the application utilizes floating-point calculations or graphics processing, accelerated computing instances will be the best among all.

  • Also, data pattern matching can be done more efficiently with this instance type.


  • 2nd Generation Intel Xeon Scalable processors, 3.0 GHz (Cascade Lake P-8275CL).

  • 8 NVIDIA A100 Tensor Core GPUs maximum.

  • 400 Gbps instance networking with support for NVIDIA GPUDirect RDMA and Elastic Fabric Adapter (EFA) (remote direct memory access).

Accelerated computing consists of mainly P1, Inf2, G5, G5g, G4dn, G4ad, G3, F1 and VT1, P4**.**

Types of Instances Pricing in EC2

Amazon EC2 supports:

  1. On-Demand Instances (the default)

  2. Spot Instances

  3. Reserved Instances

On-Demand Instances

On-Demand Instances are instances that you pay for as and when you need them. Think of these as “pay-as-you-go” instances, which you can be charged for either by the hour or by the second. You buy as much cloud computing capacity as you need, whenever you need it, with no long-term commitment. When you don’t need it anymore, you withdraw your workloads and cancel the instances, increasing or decreasing your cloud capacity as your computing needs change.

Some of the advantages of On-Demand instances are that they are scalable, flexible and stable.

Spot Instances

When you buy a Spot Instance, you’re essentially borrowing excess capacity from your cloud provider for a certain period of time. If demand goes up and your cloud provider needs that extra capacity, they’ll take it back - often with less than a minute’s notice before your workloads disappear.

Reserved Instances

Reserved Instances are configured almost exactly like On-Demand Instances. The only difference is that instead of requesting instances as and when you need them, you “reserve” instances for either one year or three years.

That commitment pays off, as Reserved Instances offer pretty significant discounts compared to On-Demand instances.

There are two types of Reserved Instances:

  • If you use Standard Reserved Instances, you can only use instances from within one instance family, on the same operating system.

  • If you use Convertible Reserved Instances, you can use instances from different families and on different operating systems.

Convertible Reserved Instances obviously give you a lot more flexibility but they’re also slightly more expensive than Standard Reserved Instances.

How to create an instance in EC2?

Step 1: Create account on AWS and on search bar type "EC2".

Step 2: Choose the location you want to create an instance from the dropdown as shown below.

Step 3: Launch an instance, by clicking on "Launch Instance".

Step 4: You will see the below page. Fill in the details like your instance name, which OS image (AMI) you want to choose.
Amazon Machine Image(AMI) : An AMI is an image that AWS supports and keeps up to date. It contains the information needed to start an instance. When you launch an instance, you must choose an AMI.

When you need multiple instances with the same configuration, you can launch them from a single AMI.

Step 5: Choose the instance type and create key pair.

Step 6: Create a key pair for your instance.

Step 7: In "Network settings", allows the traffic you want to receive or send. And leave the remaining settings as default. And then launch the instance.

Step 8: Your instance has been successfully initiated.

Step 9: You can see the instance is in "Running" state.

How to connect an instance to a Client Server?

Step 1: To connect instance to the client server, Select the instance. You will see the "Connect" button got enabled.

Step 2: Click on "Connect". You will be redirected to the page as shown below.
You can see there are 4 ways to connect to an instance. We will moving ahead with SSH Client connect.

Step 3: Perform the steps as given in the above snapshot.

NOTE: When you create a key-pair, it will get downloaded. For connecting to an instance we will be needing that key, so remember the location where you have save that file and you have to connect that instance from that location only.

As in the below case, ".pem" file which is our key-pair file is in "Downloads" location of the system.

So, for connecting to an instance we have use the command given in the above snapshot from the Downloads location where our ".pem" file is present.

ssh -i "Jenkins-key.pem"

Hence, we are connected to an instance on the client system.


Amazon Elastic Compute Cloud (EC2) is a web service offered by Amazon Web Services (AWS) that provides resizable compute capacity in the cloud.

EC2 instances enable users to run virtual servers for various computing needs, ranging from simple applications to complex, high-performance workloads.

Key features include scalability, flexibility, and the ability to choose from a variety of instance types to meet specific requirements. With EC2, users can easily launch, manage, and terminate virtual servers, paying only for the resources they consume.

Amazon Machine Image (AMI) is a pre-configured virtual machine image used to create and launch instances in Amazon Elastic Compute Cloud (EC2).
AMIs simplify the deployment process by bundling the operating system, software, and configurations into a single package. Users can create custom AMIs, share them, or use existing public AMIs. This flexibility accelerates application development, promotes consistency, and allows for easy replication of environments.

Overall, EC2 is a fundamental building block of AWS, empowering users to efficiently deploy and scale applications in the cloud. AMIs play a crucial role in the scalability and efficiency of cloud computing on the Amazon Web Services (AWS) platform.

*👆The information presented above is based on my interpretation. Suggestions are always welcome.*😊

~Smriti Sharma✌