What is EC2 in AWS? – Amazon EC2 Tutorial

Amazon EC2 is the most used AWS service. It lets users create virtual machines of their own choice of configurations. Here in this blog, you will learn what is EC2 and how it works. Towards the end, there is also a beginner-friendly demo to help you get acquainted with Amazon EC2.

What is EC2 in AWS? – Amazon EC2 Tutorial
21st Sep, 2019
1938 Views

Amazon EC2 is without any doubt the most used AWS service that lets users launch and manage server instances, at any time and for as long as one needs. Here in this Amazon EC2 tutorial, we will learn what is EC2 in AWS and how it works. Towards the end of this Amazon EC2 tutorial, there is also a beginner-friendly demo to get you started with Amazon EC2.
Let’s see the topics that will be covered in this blog:

Watch this AWS EC2 tutorial video:

What is EC2 in AWS?

Amazon EC2 is one of the most used and most basic services in Amazon so it makes sense to start with EC2 when you are new to AWS. But the first question here is, what is EC2 in AWS?

Well, to be very simple, it is a machine with an operating system and hardware components of your choice. But the difference is that it is totally virtualized. You can run multiple virtual computers in a single physical hardware.

Learn AWS from experts, click here to know more about AWS Online Training

Elastic Compute Cloud (EC2) is one of the integral parts of the AWS ecosystem. EC2 enables on-demand, scalable computing capacity in the AWS cloud.

Amazon EC2 instances eliminate the up-front investment for hardware, and there is no need to maintain any rented hardware. It enables you to build and run applications faster. You can use EC2 in AWS to launch as many virtual servers as you need. Also, you can scale up or down when there is an increase or decrease in the website traffic.

The word ‘elastic’ in Elastic Compute Cloud talks about the system’s capability of adapting to varying workloads and provisioning or de-provisioning resources according to the demand.

Why Amazon EC2?

Now that we know what is EC2 in AWS, let’s now move forward and understand Why exactly do we need Amazon EC2. AWS Elastic Compute Cloud provides a lot of benefits, let me give you an overview of what I am going to discuss.

Why do we need EC2 - what is EC2 in AWS

  • Auto-scaling
  • Pay-as-you-go
  • Increased Reliability
  • Elasticity

Want to read about AWS from scratch? Read this blog on ‘what is AWS‘ now!

Auto-scaling:

This is the benefit which makes most businesses opt for AWS EC2. It is already explained earlier how Netflix uses auto-scaling to its advantage and provides a crash-free experience.

Auto-scaling is basically providing resources according to the demand. They either scale up or scale down corresponding to the increase or decrease in demand.

If you have any doubts or queries related to AWS, do post on AWS Community.

Pay-as-you-go:

You will be charged by the hour, and you have to pay only for what you have used. A company, XYZ might be using 100 servers normally, and on Mondays it scales down to 50 servers. So, it only has to pay for 50 servers those days, not the usual fee for the usage of 100 servers.

Even when you use your Amazon EC2 instances services for a few hours, you only need to pay for that time period and nothing more.

Increased Reliability:

AWS is spread across 20 worldwide regions with 61 availability zones (AZs) which helps your business when it is expanding. Also, this will increase the load speed of your application around the world.

You can always store multiple copies of your application in multiple AZs so that when one data center fails or loses data, the application will not fail completely.

Elasticity:

Instead of 10 low-configuration machines, you could rent a single high-configuration machine with an OS of your preferred choice for your application. Elasticity is the feature from which Elastic Compute Cloud got its name.

Moving on in this what is EC2 in AWS tutorial, let’s now see different types of AWS EC2 Instance Types.

Are you preparing for AWS interview? Then here are latest AWS interview questions

AWS EC2 Instance Types

The type of an AWS instance determines the underlying hardware of the instances which are launched.

Types of EC2

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 provide a balance among compute, memory, and networking resources, and they can be used for a variety of workloads.

A1 Instances

A1 instances are used in applications that work in synchrony with the Arm ecosystem and are suitable for scale-out workloads. They are suitable for these applications:

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

Interested in learning AWS? Go through this AWS Tutorial!

M5, M5a, and M5d Instances

These instances offer a balance among compute, memory, and networking resources providing an ideal cloud design. It could be used for a wide range of applications. M5 instances are well-suited for the following applications:

  • Web and application servers
  • Small and medium databases
  • Gaming servers
  • Caching fleets

T2 and T3 Instances

These instances provide clock up or down of CPU performance. These instances are well-suited for the following applications:

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

Compute-optimized Instances

These instances are useful for compute-dependent applications that need high-performance processors. They are well suited for the following applications:

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

C5, C4, and C5n are the instances under this category.

Are you looking for AWS training in Bangalore?

Memory-optimized Instances

These instances are for delivering fast performance for processing large data sets in memory.

R4, R5, R5a, and R5d instances are memory optimized.

These instances can be used in these following applications:

  • High-performance, relational (MySQL) and NoSQL (MongoDB, Cassandra, etc.) databases
  • Applications which process real-time big data sets (financial services, Hadoop/Spark clusters, etc.)

Accelerated Computing Instances

These instances are the latest gen general-purpose instances, and they provide an accelerated performance when the CPU clock rate increases.

P3, P2, G3, and F1 are instances for accelerated computing.

P3 and P2 are general-purpose instances.

G3 is for graphic-intensive applications.

Storage-optimized Instances

Storage-optimized instances are designed for workloads that contain very large data sets which has to be written in memory and require high, sequential read and write access.

D2 instances feature up to 48 TB of HDD-based local storage and offer the lowest price-per-disk throughput performance on Amazon EC2.

H1 instances provide a balance between compute and memory and features up to 16 TB of HDD-based local storage which delivers high-disk throughput.

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

Do you want to read about AWS from scratch? Read this blog on ‘what is AWS‘?

AWS EC2 Pricing

Free Tier 750 hours of free usage up to one year is provided by AWS. Only t2.micro instance can be used on Linux and Windows AMIs.

On-demand Price:

m5.large$0.096/hour
c5.large$0.085/hour
r4.large$0.133/hour

Data Transfer IN:

FREE from any region in the world

Data Transfer OUT:

From EC2 to:

S3, Glacier, DynamoDB, SES, and SQS in the same regionFREE
S3, Glacier, DynamoDB, SES, and SQS in the same region$0.020/GB
EC2, RDS, Redshift, ElastiCache, ELB, and ENI in the same AZ with private IPFREE
EC2, RDS, Redshift, ElastiCache, ELB, and ENI in the same AZ with public IP$0.010/GB
EC2, RDS, Redshift, ElastiCache, ELB, and ENI in different AZs$0.010/GB

Knowing what is EC2 in AWS is one of the first things one must do when they are starting with AWS but it won’t do any good if you don’t know how to create an EC2 instance. Now let us create an EC2 Instance to understand better.

log on to your AWS account and let’s create your first instance.

Note: In case you are absolutely new and haven’t created your AWS Account then I recommend you to take a quick look at our Amazon AWS Management Console blog which will help you create an account within a few minutes.

Demo: Creating an AWS EC2 Instance from scratch

Step 1: Open the AWS Management Console, open services drop-down and click on EC2 under the compute category

EC2 demo

Basic steps to follow in order to create an Amazon EC2 instance is depicted in the image below:

EC2 demo

Step 2: Creation of an instance

  • First, click on Launch Instance

EC2 demo

  • Now, in the Choose AMI section, scroll down and choose Ubuntu and click on Next

EC2 demo

  • Choose the free tier eligible t2.micro Instance and proceed with Next: Configure Instance Details

EC2 demo

  • Configure instance details and then click on Next

EC2 demo

  • Next is adding storage. Here, you don’t need to change the size because for a basic Ubuntu instance it is 8 GiB

EC2 demo

  • Now add a tag with the attributes Key and Value, name them as it is in the image below. Key and Value pairs are to identify the particular instance while it is running

EC2 demo

  • Now proceed with the next step, Create a new security group, and then click on Review and Launch

EC2 demo

  • Review your instance specifications once and then launch it

EC2 demo

Step 3: Creating a new key pair

  • Choose Create a new key pair from the popup box, give a name for the key pair, and then click on Download Key Pair. Then, proceed with Launch Instances
  • Keep the downloaded key pair file in a safe location so that you can access it later

EC2 demo

EC2 demo


Step 4: Viewing your AWS instances

EC2 demo

EC2 demo

  • Wait till the launch is initiated, then click on instances under the INSTANCES option and view the instance which you have created

EC2 demo

  • Wait till your instance initializes, that is, till your 2/2 checks are done

EC2 demo

Now it gets interesting; here, you will connect the instance using an SSH client and then host your own website

Step 5: Connecting the instance through an SSH client

  • Download PuTTY: a free SSH client

Website link: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

  • Choose 32 or 64 bits according to your system’s specifications. Then, install it like you install any other application on your system

EC2 demo

  • Install PuTTY

EC2-demo

  • PuTTY only accepts private key files with the extension ‘.ppk’, so you have to convert your ubuntudemo.pem to a .ppk extension
  • Now, open PuTTYgen and load ‘ubuntudemo.pem’. A dialog box appears where you have to press OK

EC2 demo

  • Click on save private key and proceed with a Yes in the dialog box. After that store it in a location from where you can access it easily

EC2-demo

EC2-demo

  • Open PuTTY, type [email protected]”your public ip” which you can find in the description tab for your instance

EC2-demo

  • First, type Host Name in the box with the port number, 22

EC2-demo

  • Second, go to Connection → SSH → Auth. Now, click on Browse and add the .ppk file which you have created

EC2-demo

  • Click on Open and then press Yes on the PuTTY Security Alert box

EC2-demo

  • Now, you have successfully launched your Ubuntu instance!

EC2-demo

Step 6: Running a simple HTML page via this instance

  • First, update the Ubuntu instance using this command

EC2-demo

  • Then, install apache2. Apache2 is a web server which is commonly used in Linux systems

EC2-demo

  • Type the below commands to enter into that directory and check whether index.html exists

EC2-demo

  • Go back to your instances page and click on ‘launch-wizard-4’ under security groups

EC2-demo

  • Go to Inbound and click on Edit. Then, add an HTTP rule with Source as ‘Anywhere’

EC2-demo

  • On your browser, use your public IP address, put it in the URL box and run
  • You have now successfully hosted your first website via a Cloud instance

EC2-demo

  • Let’s now see how to edit and run your own HTML page instead of the Apache2 default page

EC2-demo

  • For one last time, run the public IP address of your instance in the browser

EC2-demo

Congratulations! You have created your first Ubuntu instance and have run your webpage on it!

Hope this Amazon EC2 tutorial on what is EC2 in AWS was helpful to you. This tutorial covered topics such as what is EC2 in AWS, why Amazon EC2, AWS EC2 instance types and more along with a hands-on creating EC2 instance from scratch.

 

Related Articles

Leave a Reply

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

Solve : *
3 + 27 =