6. AWS Compute Services

6.1 EC2

EC2 known as Elastic Compute Cloud is an AWS cloud virtual machine (VM) hosting service which provides on-demand and scalable computing capacity in AWS Cloud. Organizations use EC2 to launch virtual servers for their applications and services for business use case implementation. EC2 compute instances is configured with security, networking, and storage.
Leveraging EC2 instances, organizations can reduce hardware cost and develop applications quickly. Below diagram shows a simple model of EC2 instance placed inside a VPC private subnet and attached to a EBS volume.

AWS EC2

Few things to know related to EC2 instance

Name Description
Instances Instances are known as Virtual Servers used to run any program or business process. Example – It can be used to run a web service.
Amazon Machine Images (AMI) Bundled software package with server’s operating system and other required software to be installed in server. Like Linux based operating systems – Ubuntu, CentOS etc. or Microsoft Windows OS.
Instance Types Based on your computing need, you can choose your instance type. This defines the capability of computational power. Instance type varies based on CPU, memory, storage, networking capacity, any graphical processing specific hardware need etc.
Key Pairs This enabled security for login. AWS keeps the public key and client, or user stores the private key securely.
Instance store Volumes Temporary storage volume to store instance temp data, gets deleted once instance is terminated.
AWS EBS volumes This is elastic persistent storage volume attached to EC2.
Security Groups This defines the source IP addresses (along with protocols, ports) that can reach to the instance and the destination IP addresses to which instance can connect.
Elastic IP Address It is a static IPv4 public address used for dynamic cloud computing. It does not change over time. If existing EC2 instance is terminated, the same IP is assigned to newly created EC2 instance, thus failure is masked by remapping the same IP to different EC2 instance.
Tags Metadata info assigned to instance, used for reporting purpose.
Virtual Private Cloud (VPC) Virtual network in AWS cloud, used to isolate resources from other virtual network resources.

6.2 ECS

AWS Elastic Container Service (ECS) is a fully managed container orchestration service. It helps to manage, deploy, and scale containerized applications. It facilitates you to run the applications without managing the infrastructure – simply focus on the applications.
ECS manages the application availability, scale up or down to meet the capacity demands. For example, if in your website there is huge spike of user requests, so it will automatically create more containers and deploy required service instances, it will scale down once the required capacity is not required, deleting required containers. ECS has capability integrate various AWS services and third-party services for CI/CD pipeline setup and deployment through ECS API interface.

6.2.1 ECS Components

6.2.2 ECS Deployments

6.3 Lambda

AWS Lambda is an example of serverless computing. It is an event-driven service allows you to run code without considering about servers or clusters. User does not need to provision or manage servers, only requires uploading the code. AWS Lambda will run the code with required scaling ang high availability. User needs to pay only for the compute time or Lambda function is running– no change is required when code is not running. Lambda can be triggered from many AWS services, also can be invoked directly from web or mobile applications. This is also known as Function-as-a-service (FaaS). To start using Lambda in applications, following steps and configuration settings are required to follow –

6.3.1 Few business scenarios to understand the Lambda use case

A. File Processing

AWS Lambda File Processing

B. Web App

AWS Lambda Web App

C. IOT Backends

AWS Lambda IOT backend App

6.3.2 Custom Back End Services

Lambda can be used to create new backend application services using Lambda API or custom API endpoints using AWS API Gateway.

6.3.3 Bring your own code

Lambda supports C#, Java, Go, Node.js, PowerShell, Python, and Ruby code natively. Also, developer can use third-party libraries. It also provides Lambda Layer to package code (SDK, libraries etc.) and reuse for multiple functions.

6.3.4 Automated Administration

Lambda deploys the code and run it without any need to do administrative, maintenance and security patches tasks.

6.3.5 Built-in fault tolerance

Lambda has built-in fault tolerance mechanism. No need of maintenance windows or scheduled downtime. Lambda manages the compute capacity in multiple AZs in each region to protect the execution failure from any single point.

6.3.6 Autoscaling

Lambda can scale automatically as the request frequency increases. No manual configuration is required to support scaling.

6.3.7 Package as containerized image

Lambda supports containerized image deployment as well. Organization can use containerized image for both Lambda as well as normal application deployment consistently.

6.3.8 Connect to relational database

Developer can use AWS RDS Proxy which creates thousands of concurrent connections to efficiently connect to Relational databases from serverless applications or Lambda. Currently, it supports only for MYSQL and Aurora databases.

6.3.9 High Performance

To achieve high performance, responding clients in double-digit milliseconds, developer can choose ‘Provisioned Concurrency’ and configure it, so Lambda will keep the functions initialized to start it quickly to respond with low latency.

6.3.10 Connect to shared file system

EFS for Lambda is used to securely read/write persistent data at scale and share the files with other stateless instances or containerized applications.

6.3.11 Run at Edge

Based upon AWS CloudFront events, Lambda can run code at AWS Edge locations globally to perform low latency content delivery.

6.3.12 Multiple Lambda Orchestration

Organization sometimes requires workflow to build applications with complex stateful business process, long-running tasks involving multiple sequential, parallel, conditional steps, error handling steps etc. AWS Step Functions can be built to coordinate multiple Lambda functions in the workflow steps.

6.4 Auto Scaling

AWS autoscaling service helps applications to scale based on need optimize cost and performance. It monitors applications and automatically detects the capacity need and adjust it either through scale up or down and manage the performance with optimal cost. IT can be configured for many AWS Servies like – EC2 instances, AWS ECS tasks, AWS DynamoDB tables, Aws Aurora replicas etc. You can create AWS Auto scaling group with collection of EC2 instances mentioning the minimum number of EC2 instances and maximum number of EC2 instances and desired number of instance capacity. Autoscaling group will ensure that instance count will not go below minimum and beyond maximum number of instances. If scaling policies is defined it will increase or decrease the EC2 instances accordingly.

6.5 Load Balancers

Load Balancers mange the traffic flow from the user’s device to servers to distribute the load to deliver good user experience, maintain high availability to protect from single point failure of resources. Load balancer monitors the health status and perform routing to target servers – web servers, application servers across different environment – on-premises, multiple cloud environments with different infrastructure including VMs, managed container instances, on-premises bare metal servers.
Load Balancing is a process to distribute the network traffic to a pool of resources – like EC2 instances, containers, IP addresses, multiple availability zones. Elastic load balancing scales the load balancer based on the traffic changes over time. There are many types of load balancers. Load balancers monitor the health of registered targets and route request to healthy targets to maintain the application availability to user automatically.

Load Balancer

6.5.1 Application Load Balancers

This Load Balancer distributes the incoming application traffic to different EC2 instances in multiple availability zones. User can add one or more listeners to load balancer. Listener checks the connection requests from client based upon the protocol and port configured. There are rules attached to listener. Rule consists of priority, one or more actions, one or more conditions. If rules are met, load balancer will route to its targets. Targets are registered with Target group. One target can be registered with multiple target groups. Each target group routes requests to one or more registered targets.

Application Load Balancer