Introduction to AWS EC2

Deepak Sharma
tech_vichaar
Published in
6 min readJan 12, 2020
PC: Unsplash

Amazon EC2 stands for Elastic Compute Cloud. It is a Web Service of AWS ecosystem that provides resizable compute powers in the cloud. It is a service where we can roll-up servers as per our compute requirements.

EC2 is a go-to option when requirements contain a secure, scalable and developer-friendly compute environment. It pulls out the need for setting up any physical servers or does any long term commitments. Instead user can get going in minutes in few clicks with an uptime commitment of 99.99%.

In simple terms, EC2 provides an operating system on top of which applications can run.

Features of EC2

  • Scalable Instances.
  • Configurable server parameters which include size, compute powers and networking capabilities of rolled-up instance.
  • Instances can be scaled up to serve additional traffic and scaled down to witness cost savings at any point in time.
  • Allows secure management of servers via SSH
  • Firewall activated for prevention of any intruder attacks.
  • PCI DSS Compliance for secure processing, storage and transmission of credit card data.

Pricing

Photo by Geronimo Giqueaux on Unsplash

EC2 have free-tier instances also but to leverage all features of a rolled-up instance, it has the following pricing models:

  • On-Demand Instances: It is a pay-as-you-go model. It is the default payment model for each new instance and hence requires no commitments at all. Use cases include Test Instances, Temporary Instances etc.
  • Savings Plans: User commits to a consistent amount of usage for 1–3 years, for which AWS offers usage discounts. These include some moderately traffic generating applications. Use case includes Personal Applications, Blogs etc.
  • Reserved Instances: Upto 75% of discounts with respect to On-demand instances can be availed when a user commits on further usage parameters. Here one can commit to a reserved capacity of an instance, size and region for 1–3 years. Maximum savings are observed on upfront payments for longer duration. Scheduled instances will also be available for a specific time window. Best for Applications having predictable usage patterns along with steady states. Use case includes E-Commerce Application etc.
  • Spot Instances: Unused EC2 instances are available for bidding. We can bid to get the best price. This model holds beneficial if our application has a flexible start and end time. Go to option for an urgent need of a large amount of computing capacity. Use case includes Periodic cron Jobs, Instances required for Weekly sales, Data Science Model trainings etc.
  • Dedicated Hosts: Unlike others, it is an exclusive physical dedicated server reserved for single user use only. It is beneficial for applications which seeks maximum server uptime. This model is costly among all. Use cases includes Banks, Heath Institutions etc where data security and uptime is utmost priority.

Cost is an important factor in deciding the type of model to use. AWS provides Total Cost of Ownership(TCO) calculator to perform cost estimations.

Amazon Machine Image (AMI)

AMI Architecture

Similar to the Docker image, Amazon Machine Image (AMI) is a template that provides almost every configuration, our deployed application needs. For Example, our Application needs Python 3.7 run time environment along with MySQL to run smoothly. We can make respective AMI configuration template and use it to deploy our multiple application instances.

Amazon Marketplace has community published AMI templates for use.

Regions and Availability Zones

In Simple Terms, Regions are place where we wish to deploy our application. AWS Regions are data isolated geographical area spread across the world. Each region can be segmented into multiple Availability Zones. Every Availability Zone in a region are connected together with low latency data links.

Region Architecture

For an Ideal scenario, Region should be closest to Traffic served. For Example, If an application has intended users from India only, Ideal region would be Asia Pacific (Mumbai) only, because its closest to traffic served and hence lowest latency for traffic to access its services will be observed. Deployed Application should be replicated to multiple regions across world for maximum availability and lowest latency to user base spread over world.

EC2 Instance Types

During Provisioning any EC2 first instance on AWS, After Selecting AMI, it comes selecting EC2 Instance types:

EC2 Instance Types
EC2 Instance Types

Suffix Integer in each of category refers to generation of an instance. T2 refers to second generation of instance type.

  • General purpose: General purpose instances provide a balance of compute, memory, and network resources, and are a good choice for many applications. They are recommended for small and medium databases, data processing tasks that require additional memory, caching fleets, and for running backend servers for SAP, Microsoft SharePoint, and other enterprise applications.
  • Compute Optimized: Compute optimized instances have a higher ratio of vCPUs to memory than other families, and the lowest cost per vCPU among all Amazon EC2 instance types. AWS recommends compute optimized instances for running CPU-bound scale out applications.
  • FPGA instances: FPGA instances provide customizable field programmable gate arrays that can be programmed to create application specific hardware accelerations, along with high CPU performance, large memory and high network bandwidth for applications requiring massively parallel processing power.
  • GPU Instances: GPU instances provide graphics processing units (GPUs) along with high CPU and network performance for applications benefiting from highly parallelized processing, including 3D graphics, HPC, rendering, and media processing applications.
  • Memory Optimized: These types of instances have lowest cost per GB amoung other types. AWS recommends usage of such instance type for deployments of memory intensive tasks like Database deployments, Memcached and other distributed caches.
  • Storage Optimized: Storage optimized instances provides us with direct-attached storage options optimized for applications with specific disk I/O and storage capacity requirements.
  • Machine Learning ASIC Instances: Machine learning ASIC instances are powered by chips custom built by AWS and are optimized for running machine learning applications such as image recognition, speech recognition, natural language processing and personalization.

Elastic Load Balancer

PC: AWS

For Applications having multiple replicas, there exists at top a routing table which intelligently decides where to route incoming packets. This intelligent routing table called as Load Balancer. Load Balancers are made to operate on OSI layers 7 or 4. Apart from Traffic routing load Balancers are do used for varied purposes which include IP masking, Firewalls, replica liveness checks, SSL Certificate managements etc.

Types

  • Application Load Balancer: Mainly for HTTP, HTTPS traffic. Operates on OSI layer 7. It can make intelligent decisions based on Application performance. They can be used to forward specific request to specified web servers.
  • Network Load Balancer: Mainly for TCP, TLS and UDP Traffic. Operates on OSI layer 4. It can offer extreme performance at ultra low latency. Mainly used for IoT Devices.
  • Classic Load Balancer: Can server both TCP and HTTP traffic. It is legacy load Balancer. These can operate on OSI layer 7 or OSI layer 4 based on configurations. Not Recommended by AWS for any new deployments.

Load Balancer throws 504 error or Gateway Timeout if application doesn’t responds within time limits.

Classic Load Balancer and Application load Balancers masks IP address of external request with Private IPs (10.0.0.23) and appends same in headers as `x-forwarded-for` key.

Summary

  • EC2 provides Infrastructure as Code service for Application deployment in minutes.
  • Selecting right payment model is quite important for cost effectiveness.
  • Application Instances deployed on EC2 are scalable.
  • Elastic Load Balancer helps in intelligently routing traffic to EC2 instances.
  • EC2 can be used for Bare Metal and On-Prem Instances.

Catch me on LinkedIn.

--

--

Deepak Sharma
tech_vichaar

Software Engineer @RedHat. Loves R&D, DevOps, and Engineering. Football and Chess are Love. https://finddeepak.com