What is Amazon EC2

Amazon Elastic Computation Cloud (Amazon EC2) is a cloud computing web service that offers resizable compute power. It is intended to simplify web-scale computing for developers.

Amazon EC2 enables the creation of virtual server instances in the AWS cloud.

Each virtual server instance is denoted by the term “instance”.  With the Amazon EC2 web interface or an application programming interface, an AWS user can raise or reduce instance capacity as needed within minutes of logging into their account (API). With AWS Auto Scaling, a developer can programme an application to automatically extend instances as needed. Using an autoscaling policy and group, an user can manage several instances of the application at the same time.

You are limited to running a maximum of 20 On-Demand instances across all instance families, purchasing a maximum of 20 Reserved Instances, and requesting Spot Instances based on your region’s dynamic spot restriction (by default).

At the moment, Amazon EC2 supports the following operating systems: Amazon Linux, Ubuntu, Windows Server, Red Hat Enterprise Linux, SUSE Linux Enterprise Server, Fedora, Debian, CentOS, Gentoo Linux, Oracle Linux, and FreeBSD.

EC2 compute units (ECU) are a unit of measurement for an Amazon EC2 instance’s integer processing power.

Connecting to an EC2 instance:

The Amazon EC2 setup process begins with the creation of an Amazon Machine Image (AMI), which contains an operating system, applications, and configurations. After uploading the AMI to Amazon Simple Storage Service (S3) and registering it with EC2, users can launch virtual machines as needed.

You have complete control over the operating system layer using EC2.  To connect securely to EC2 instances, key pairs are used:

  • A key pair consists of an AWS-stored public key and a file containing your private key.
  • The private key file is necessary for Windows AMIs in order to acquire the password used to log into your instance.
  • The private key file for Linux AMIs enables you to remotely SSH (secure shell) into your instance.

Amazon provides a number of EC2 instance types to meet a variety of requirements and financial constraints, including hourly, allocated, and spot rates.

Benefits of EC2

There are numerous advantages to using EC2. One of most major benefits of AWS EC2 is its ability to provide elastic load balancing. inbound application traffic over several instances, while also identifying unhealthy instances and redirecting traffic to the healthy versions until they are rebuilt.

  • EC2 can be used for a variety of different reasons.
  • EC2 can be used to deploy web applications and middleware.
  • EC2 can be used to migrate data across sources.
  • EC2 is a cloud computing platform that may be used for data mining, integration, and transformation.
  • EC2 enables scaling up and scaling down by managing instance types.
  • EC2 would require frequent security patch updates, posing a management burden. Amazon routinely provides updated AMIs (Amazon Machine Images) that include the newest updates. The customer must upgrade the EC2 instance to the most recent AMI. This is not easy labour, but it may be achievable with the aid of automated scripts. However, it is a time-consuming task.

Perhaps the most significant benefit – aside from the scalability and flexibility, the cost structure, and the instance kinds offered – is that any business, not just large enterprises with enterprise-level demands, can get started on EC2. Even a small startup can sign up for EC2 and launch their new web application with just a single instance. There are no restrictions on who can use EC2 or what they can do with it.

Amazon EC2 instance features

Customizable EC2 instance features include storage, the amount of virtual processors and RAM accessible to the instance, the instance’s operating system, and the AMI upon which the instance is based. The following are characteristics of Amazon EC2 instances:

Functioning system. EC2 supports numerous operating systems, including Linux, Windows Server, CentOS, and Debian.

Permanent storage Amazon’s Elastic Block Storage (EBS) service enables block-level storage volumes to be attached to EBS, the amount of storage available to an EC2 instance can be increased or decreased, and EBS volumes can be attached to many instances.

Dynamic IP addresses Amazon’s Elastic IP solution enables the association of IP addresses with instances. Moving elastic IP addresses from one instance to another does not require the assistance of a network administrator. This makes them excellent for use in failover clusters, load balancing, and other scenarios where many servers running the same service are required.

The Amazon CloudWatch service. This web service permits monitoring of AWS cloud services and AWS-deployed applications. CloudWatch is capable of collecting, storing, and analysing both historical and real-time performance data. It may also monitor applications proactively, enhance resource use, optimise expenses, and scale up or down based on fluctuating workloads.

Automatic scalability. In response to application demand, Amazon EC2 Auto Scaling dynamically adds or removes capacity from Amazon EC2 virtual servers. Auto Scaling gives additional capacity to manage transitory spikes in traffic during a product launch, or to raise or decrease capacity based on whether usage exceeds or falls below a certain threshold.

Unadorned instances. The hardware resources for these virtual server instances include a processor, storage, and network. They are not virtualized and do not run an operating system, which reduces their memory footprint, increases their processing power, and provides additional security.

Fleet of Amazon EC2 servers. This service allows instances to be deployed and managed as a single virtual server. The Fleet service enables launching, stopping, and terminating EC2 instances across all instance kinds with a single operation. Amazon EC2 Fleet also offers API-based programmatic access to fleet operations. Integration of fleet management with existing management tools is possible. Policies may be adjusted using EC2 Fleet to automatically alter the size of a fleet to the workload.

Stop and restart instances. Instances of EC2 can be halted and later resumed from the same state. For instance, if an application utilises an excessive amount of resources, it can be suspended without incurring instance usage fees.

Billing and Provisioning

  • Pay for hours worked on a per-hour basis with no obligation.
  • Cost-effectiveness and adaptability with no up-front costs.
  • Ideal for automatically scaling groups and workloads that fluctuate.
  • Excellent for development/testing.
  • Spot Instances on Amazon EC2 enable you to take advantage of unused EC2 capacity in the AWS cloud.
  • Spot Instances are available at a savings of up to 90% off On-Demand rates.
  • Spot Instances can be used for a variety of stateless, fault-tolerant, or flexible applications, including big data, containerized workloads, continuous integration/continuous delivery (CI/CD), web servers, high-performance computing (HPC), and other test and development workloads.
  • You can request Spot Instances via the Spot administration console, the Spot command-line interface, the Spot API, or the same interface used to launch On-Demand instances by specifying the Spot option.
  • Additionally, you can use a Launch Template or a pre-configured or custom Amazon Machine Image (AMI) to configure your Spot instance’s security and network access, select from a variety of instance types and locations, use static IP endpoints, and attach persistent block storage to your Spot instances.
  • The new pricing model is based on long-term patterns in the supply and demand for EC2 spare capacity.
  • No instances are halted as a result of higher rival offers.
  • Spot Instances receive a two-minute disruption notice when their capacity is due to be recovered by EC2.
  • Diversify and operate your application across various capacity pools to mitigate the impact of interruptions and optimise Spot Instances.
  • Each instance family, instance size, Availability Zone, and Region corresponds to a distinct Spot pool.
  • To further mitigate the impact of interruptions, you may configure Spot Instances and Spot Fleets to respond to an interruption alert by pausing or hibernating instances rather than terminating them.


  • Purchase (or agree to purchase) EC2 instance usage in advance and save significantly on On-Demand pricing.
  • When used in a specific AZ, it establishes a capacity reservation.
  • When you launch an instance that matches your bought RI, AWS Billing automatically applies discounted prices.
  • Capacity is held for a period of one or three years.
  • Standard, convertible, and scheduled RIs are available in EC2.
  • Standard = a one- or three-year commitment, regardless of whether it is on or off.
  • Scheduled = allocated for particular periods of time, prices accrue hourly, and are invoiced monthly over the term (1 year).
  • Scheduled RIs associate your capacity reservation with a recurrent, predictable timetable.
  • The table below summarises the distinctions between standard and convertible RIs.
  • RIs are utilised for predictable consumption and steady state workloads.
  • This is an excellent solution for applications that require reserved capacity.
  • Payments in advance can help reduce the hourly cost.
  • Can change AZs within an area.
  • Can modify the size of an instance inside the same instance type.
  • Modifications to the instance type are supported on Linux only.
  • Windows RIs’ instance size cannot be changed.
  • Billed regardless of whether the vehicle is running or not.
  • Possibility of selling reservations via the AWS marketplace.
  • Can be utilised in Groups with Auto Scaling.
  • Appropriate for use with Placement Groups.
  • Can be shared across several Consolidated Billing accounts.
  • If you no longer require your Reserved Instances, you can sell them on the Reserved Instance Marketplace.

RI Attributes:

  • The instance type specifies the CPU, memory, and networking capabilities of the instance.
  • Linux, SUSE Linux, Red Hat Enterprise Linux, Microsoft Windows, and Microsoft SQL Server.
  • Tenancy is classified as either a default (shared) tenancy or a dedicated tenancy.
  • Optional Availability Zone (AZ) – if specified, RI is reserved and the discount is applied to that AZ (Zonal RI). Without specifying an AZ, no reservation is formed; however, the discount is applied to any instance in the family in any AZ in the area (Regional RI).

Comparing Amazon EC2 Pricing Models

The following table provides a brief comparison of On-demand, Reserved and Spot pricing models:




No upfront fee

Options: No upfront, partial upfront or all upfront

No upfront fee

Charged by hour or second

Charged by hour or second

Charged by hour or second

No commitment

1-year or 3-year commitment

No commitment

Ideal for short term needs or unpredictable workloads

Ideal for steady-state workloads and predictable usage

Ideal for cost-sensitive, compute intensive use cases that can withstand interruption

Dedicated hosts:

  • Physical servers that are exclusively for your use.
  • After that, you have complete control over which instances are deployed on the host.
  • Available on-demand or with a reserved Dedicated Host.
  • This is useful if you have server-based software licences that employ per-core, per-socket, or per-VM metrics.
  • Each dedicated host is limited to running a single EC2 instance of the specified size and type.
  • Excellent for ensuring regulatory compliance or meeting licence requirements.
  • Performance that is predictable.
  • Isolation in its entirety.
  • The most costly option.
  • Billing is done on a per-host basis.

Specialized instances:

  • Virtualized instances on dedicated hardware are created just for you.
  • Additionally, it makes use of physically dedicated Amazon EC2 servers.
  • Does not provide dedicated hosts’ enhanced visibility and control (e.g. how instance are placed on a server).
  • Billing is on a per-instance basis.
  • It is possible for this instance to share hardware with other non-dedicated instances in the same account.
  • On-Demand, Reserved, and Spot Instances are all available.
  • Additional $2 per hour for each region.

Instance Types

Amazon EC2 offers a diverse range of instance types that are designed for specific use cases.Instance types come in a variety of CPU, memory, storage, and networking configurations, allowing you to choose the optimal resource mix for your applications.

Each instance type supports one or more instance sizes, which enables you to scale your resources according to the demands of your desired workload.

There are several types of AWS instances with different configurations and benefits.

  • General purpose
  • Compute optimized
  • Memory-optimized
  • Accelerated Computing
  • Storage optimized

General-purpose Instances

General-purpose instances balance computation, memory, and networking resources and are suitable for a wide variety of applications.

A1 Instances

A1 instances are employed in applications that operate in lockstep with the Arm ecosystem and are well-suited for scaling-out workloads. They are appropriate for the following applications:

  • Web servers
  • Containerized microservices
  • Caching fleets
  • Distributed data stores
  • Applications that require the Arm instruction set

M5, M5a, and M5d Instances

These instances strike the optimal balance of computing, memory, and networking resources, resulting in an ideal cloud architecture. It has a wide variety of potential applications. The following apps are well-suited to M5 instances:

These instances enable the CPU’s performance to be increased or decreased. These instances are ideal for the following purposes:

  • Websites and web applications
  • Code repositories
  • Development, build, test, and staging environments
  • Microservices

Compute-optimized Instances

These instances are excellent for compute-intensive applications that require powerful processors. They are particularly well suited for the following uses:

  • Batch processing workloads
  • High-performance web servers
  • High-performance computing (HPC)
  • Scientific modeling
  • Dedicated gaming servers and ad serving engines

GPU instances: GPU instances enable the faster execution of graphics-intensive applications than normal EC2 instances. Examples of GPUs include Linux distributions, which frequently make use of GPUs to render graphical user interfaces, improve compression, and speed, among other things.

Memory-optimized Instances

These instances are used to provide high-performance memory-based processing of big data sets.

The instances of R4, R5, R5a, and R5d are memory optimised.

These examples are suitable for the following purposes:

High-performance relational (MySQL) and NoSQL (MongoDB, Cassandra, etc.) databases Applications that analyse massive amounts of data in real time (financial services, Hadoop/Spark clusters, etc.)

Accelerated Computing Instances

These are the latest-generation general-purpose instances, which give enhanced performance as the CPU clock rate increases.

Accelerated computing is demonstrated by the P3, P2, G3, and F1 processors.

P3 and P2 are instances that can be used for any purpose.

The G3 processor is optimised for graphics-intensive applications.

Storage-optimized Instances

Storage-optimized instances are geared for applications that require very large data sets to be written to memory and demand high-throughput sequential read and write operations.

D2 instances provide up to 48 TB of local storage and provide the best price-per-disk performance on Amazon EC2.

H1 instances strike a mix between compute and memory, with up to 16 TB of local storage based on hard disc drives that deliver fast disc throughput.

I3 instances offer SSD-backed Non-Volatile Memory Express (NVMe) instance storage that is optimised for low latency, very high random I/O performance, high sequential read throughput, and high IOPS at a reasonable cost.


An Amazon Machine Image (AMI) contains all of the data necessary to begin an instance.

An AMI consists of the following:

  • A template for the instance’s root volume (for example, an operating system, an application server, and applications).
  • Permissions for instance launch that specify which AWS accounts can utilise the AMI to deploy instances.
  • A block device mapping that specifies which volumes should be attached to the instance during startup.

AMIs are regional in scope. AMIs can be launched only from the region in which they are stored. However, you can use the terminal, command line, or the API to copy AMIs to other regions.

EBS or Instance store volumes are associated to the instance:

  • Amazon Elastic Block Store (EBS) is a persistent storage service provided by Amazon. The volume is created using EBS snapshots stored on Amazon S3.
  • Volumes in instance stores are transient (non-persistent). This signifies that data is lost when the instance is terminated. The volume is created using a template available on Amazon S3.

IP Addresses

An Amazon EC2 instance can be issued one of three types of IP addresses:

  • Public – a public address that is automatically assigned to instances located in public subnets and is reassigned when the instance is stopped/started.
  • Private — All instances are immediately granted a private address.

Elastic IP – a static public address.

When an instance is halted, all public IPv4 addresses are destroyed, but private IPv4 and IPv6 addresses are kept.

If you restart the instance, the public IPv4 addresses are maintained.

When the instance is terminated, the elastic IPs are preserved.

Static public IP addresses that can be remapped (moved) between instances are referred to as elastic IP addresses.

By default, all accounts are limited to five elastic IP addresses per area.

AWS charges for unused elastic IP addresses.

Elastic IP addresses are intended for use in a single region.

You may categorise your Elastic IP addresses by assigning custom tags to them.

By default, Amazon Web Services instances include a private IP address assigned to the principal network interface (eth0).

For instances located in public subnets, public IP addresses are assigned (VPC). Instances in EC2-Classic are always assigned public IP addresses.

Configuring DNS records for elastic IPs is as simple as filling out a form.   Secondary IP addresses might be advantageous for hosting many websites on a single server or for traffic redirection to a standby EC2 instance for high availability.

You have the option of allowing secondary IP addresses to be reassigned. A single private IPv4 address can be associated with a single Elastic IP address and vice versa.

When an IPv4 to Elastic IP address is reassigned, the IPv4 to Elastic IP association is maintained.

When a secondary private address is de-assigned from an interface, the Elastic IP address associated with it is also de-assigned. While EC2 instances are active or stopped, you can assign or remove IP addresses.

When an IP address (IPv4 or IPv6) is detached or transferred to another instance, it remains attached to the network interface.

You can attach a network interface to an instance located in a different subnet as long as the instance is contained inside the same AZ.

Elastic Network Interfaces

An elastic network interface (in this documentation, referred to as a network interface) is a logical networking component in a VPC that represents a virtual network card.

A network interface may have the following characteristics:

  • A primary private IPv4 address from your VPC’s IPv4 address range
  • A secondary private IPv4 address or multiple secondary private IPv4 addresses from your VPC’s IPv4 address range
  • Per private IPv4 address, one elastic IP address (IPv4)
  • There is one public IPv4 address available.
  • A single or several IPv6 addresses
  • One or more security organisations
  • A media access control (MAC) address
  • A check for source/destination

A brief summary

In your account, you can establish and configure network interfaces and attach them to instances in your VPC.

You cannot team an instance by adding ENIs.

The principal network interface, eth0, cannot be relocated or removed.

By default, when an EC2 instance is launched, only eth0 is created as an Elastic Network Interface (ENI).

Additional interfaces can be added to EC2 instances (the number depends on the instance family/type).

An ENI is associated with an AZ, and you can choose the subnet/AZ to assign the ENI to.

You can configure a specific IP address within the subnet or allow it to be auto-assigned.

When launching, you can only attach one additional ENI, but more can be added later.

ENIs can be “hot connected” to instances that are already operating.

When an instance is stopped, ENIs might be “warm-attached.”

When an instance is launched, ENIs can be “cold-attached.”

If you install a second interface, Amazon Web Services will not assign eth0 a public IP address (you would need to add an Elastic IP).

When an instance is ended, the default interfaces are terminated as well.

By default, manually introduced interfaces are not ended.

You have the ability to modify the termination behaviour.

Enhanced Networking – Elastic Network Adapter (ENA)

Increased networking capacity, higher packet-per-second (PPS) speed, and continuously decreased inter-instance latencies are all benefits of enhanced networking.

An Elastic Network Adapter enables enhanced networking (ENA).

If your packets-per-second rate looks to have hit its limit, you should consider upgrading to advanced networking, as you have very certainly exceeded the VIF driver’s upper thresholds.

At the moment, AWS enables increased networking capabilities through the use of SR-IOV.

SR-IOV enables direct access to network adapters, resulting in increased performance (packets per second) and decreased latency.

Must start an HVM AMI with the necessary drivers.

Available for a limited number of instance types.

Only VPC is supported.

Elastic Fabric Adapter (EFA)

Elastic Fabric Adapters are enhanced versions of AWS Elastic Network Adapters (ENAs).

Although an EFA can still handle IP traffic, it also offers a critical access paradigm known as OS bypass.

This paradigm enables the programme to use the network interface without involving the operating system in each message (most typically via some user-space middleware).

Elastic Fabric Adapter (EFA) is a network interface for Amazon EC2 instances that enables users to deploy applications at scale that require high volumes of inter-node communication on AWS.

Its custom-built operating system (OS) interface bypasses hardware to improve inter-instance communication performance, which is important for scaling these applications.

EFA enables scaling of High Performance Computing (HPC) programmes that use the Message Passing Interface (MPI) and Machine Learning (ML) applications that use the NVIDIA Collective Communications Library (NCCL).

As a result, you get on-premises HPC cluster performance combined with the elasticity and flexibility of the AWS cloud.

EFA is a free EC2 networking capability that you may enable on any compatible EC2 instance.


Add a Comment

Your email address will not be published. Required fields are marked *


My name is Nohman Habib and I am a web developer with over 10 years of experience, programming in Joomla, Wordpress, WHMCS, vTiger and Hybrid Apps. My plan to start codingace.com is to share my experience and expertise with others. Here my basic area of focus is to post tutorials primarily on Joomla development, HTML5, CSS3 and PHP.

Nohman Habib

CEO: codingace.com

Request a Quote

PHP Code Snippets Powered By : XYZScripts.com