The backbone of AWS - EC2(Pre-requisites)

The first service we explore is EC2 - Elastic Compute Cloud. This is the backbone of AWS; if you understand it, you usually get the concept of cloud computing.

Disclaimer: This is not like 'how to create an EC2 within seconds' but rather 'why we do what we are about to do! So it may help you with some basic understanding. This may take longer.

When you develop an application and serve that application to the end user in a traditional way, you should buy the required hardware like servers, RAM, and storage space. To choose the specification like Drives - SSD/HDD or RAM spec or processor types, you need to plan for at least five years so that we won't get into any trouble shortly because of lack of capacity. This results in huge setup/upfront costs for any business.

Now cloud computing comes to the rescue, and the corresponding solution in AWS is EC2.

Elastic = We can scale up or down automatically depending on requirements like storage, processor, or RAM specs.
Compute Cloud = You don't have to buy all hardware on your premise --> Cloud computing!

We know AWS is based on pay-as-you-go. That is one of the founding principles and cost optimization techniques.

How EC2 implements pay-as-you-go?

Say a server can handle 100 users at a time.

If we have 1000 users on weekdays, we need ten servers.

If it is the weekend, the user may go up to 10000; a Hundred servers are required.

If it were a traditional model, we always design for the worst-case scenario so that we would buy 100 servers upfront. This is inefficient because we only need 100 servers on weekends (2 days) and not for the whole week.

Assume server cost per day is 5 rupees(Not really, just for explanation) in AWS.

Now AWS EC2 will have to handle auto-scaling and pay-as-you-go.

EC2 will automatically scale up or down the servers depending on the end-users traffic, which we will see later.

Here the cost incurred would be,

10 server cost for 5 days(weekdays) + 100 server cost for 2 days(weekend)


10*5*5 + 100*2*5 = 1250 per week

This concept is called pay-as-you-go in AWS.

Before diving deep, creating EC2 in AWS is like buying a laptop/desktop. Therefore we need to have some basic knowledge of some terms with which I know you are familiar.

Here we are not buying a physical laptop/desktop but creating the same in a virtual space(AWS). Therefore it is called Instances in EC2.

Then what about specs?

When we develop an application, we code or program it to fulfill its purpose. We use variables in code that should have memory space, which is dynamic and temporary because they can have any value depending on user input. But the app's logic (i.e., the program) remains static and needs to be permanent.

It would be best to handle more logic with the user's screen in game development or video editing. Also, your application must be connected to the network(Internet) to communicate with the outside world(the end-user).


To execute code = We need Processors = CPU.

To perform calculations based on variables in code = We need Memory or RAM = Temporary.

To store the program or code = We need Storage = Hard disk = Parmanent.

If you want 3D modeling, rendering, and game development = You need a Graphics card = GPU.

If you want to communicate with others over the network = We need Network Interface Card(NIC) = IPs, Subnets, etc.

We need special software to coordinate the above components = Operating System(OS).

So creating an Instance in EC2 configures the above components for application-specific purposes like Video editing, Inventory management software, ERP, CRM, etc.

Understanding AWS Infrastructure:

We need to get the idea of AWS infrastructure because we get Infrastructure as a Service(IaaS).

Let's start with the known things at hand. I hope everybody uses Facebook, Gmail, G-drive, or any SaaS product. Where do you think the status you update on Fb or file you store on G-drive, or the video you watch on the YouTube store?

The answer is Data Center is situated hundreds of kilometers from your location.

What does the Datacenter have? Bunch of Computing units (Storage and Processors), Networking devices(Routers, Switches, Gateways, etc.), and other systems to support it like cooling, power supply, etc.

The geographical area where the AWS data centers are located is called AWS Region.

Note: I use the plural - Data centers because this sets AWS apart from other cloud providers.

AWS has many data centers within regions, and many data centers within the region's area are grouped. This individual group or cluster of data centers is called Availability Zones(AZ). I know it sound's confusing! Let me be clear!

Data center = Collection of Data centers = Availability Zones(AZ) = Collection of AZ's within certain certain geographical radius = AWS regions

Each AZ is independent of the other. Every AZ has a separate network, power supply, cooling systems, etc.

Refer here for AWS global infrastructure.

Understanding Network in AWS:

Networking's real purpose is communication. This communication can be with the outside world or within AWS services like Db and Web server or update process of third party software like OS, etc.

Basics of Network: Simplified version!

  • When you want to communicate, you need to be inside a network - Private Network, LAN, WAN, MAN, etc.

  • Every device in the network is called Hosts.

  • There can be many hosts within a network, and each should have a unique communication address. This address is called the IP address.

  • Ipv4 address has a shorter bit(32 bit), whereas Ipv6 has a larger bit(128 bit).

  • Since Ipv4 can only give 2^32 addresses, it is insufficient to allocate all hosts in the network a unique address.

  • But all companies and ISPs are used to Ipv4, and their devices are configured for Ipv4 like Routers, switches, etc. Therefore we use Ipv4 instead of Ipv6. Anyway, the Ipv6 transition is taking place slowly. This is a long story short!

  • Remember: Using Ipv4, address are rotated within 2^32 possibilities.

  • There may be many hosts and, eventually, IP addresses within networks. This takes more time to find a particular IP address. Therefore we group them called Subnetting.

  • Subnets = Small networks within the larger network.

  • Smaller networks are created from the larger network. If the smaller networks are called subnets, the parent network from which subnets are made would be Supernet.

  • Subnetting is dependent on the supernet. Subnet Ip-addresses are dependent on Supernet from which it is created.

  • If we can create more Ip addresses from a supernet, supernet Ip addresses must not be single values and should be a range of Ip addresses. This range is called the CIDR range.

  • The CIDR range is expressed in CIDR notation.

  • If the subnet has access to outside internet - It is Public, and if it does not, it is Private.

  • When you want to communicate between networks(subnets, supernets, outside world), we need Routers.

  • Each router has a routing table with information about all network IPs and the host it addresses.

  • If you want to get out of the network, i.e., IP address not available in the routing table. The communication goes to a component called Gateways.

Key terms:

  • IP addresses

  • IPv4

  • Subnets and Supernets

  • CIDR and CIDR notation

  • Routers and Routing Table

  • Gateways