DevOps Training
  • DevOps
  • What is DevOps
    • What DevOps Look like
    • Why DevOps Needed
    • DevOps Automation Tools
    • DevOps Principles
  • cloud computing
    • How DevOps links with Cloud Computing
    • What is cloud computing?
      • Platform as a service (PaaS)
      • Infrastructure as a service (IaaS)
      • Software as a service (SaaS)
      • Function as a Service
      • SaaS, PaaS, IaaS
  • Version Control
    • Git as Version Control
      • Setting up Remote Repo
      • Git Hooks
      • github vs gitlab vs bitbucket
      • Quick Recap Git
  • DevOps #01 Continuous Integration
    • Continuous Integration & Continuous Delivery
      • Understanding CI Tools
      • Prerequisite
      • Continuous Integration
      • CI Tools
      • Travis-CI
        • Travis CI with S3
        • Static Site Build S3
        • Beanstalk with AWS CLI
          • Elastic Beanstalk with Travis CI
        • Travis using Code Deploy EC2
          • Github and Code Deploy
          • Travis CI with Code Deploy
      • Gitlab-CI
        • CI Setup for application
        • Gitlab Runners on EC2
        • CI Integration with AWS
          • Deploying App using Gitlab CI
          • Gitlab CI with AWS S3
          • Gitlab CI with ECS
          • CI Integration with EC2
            • Update and Clean Gitlab.yml
        • Install Gitlab on EC2
      • CI/CD using Jenkins CI
        • Jenkins Build on EC2
        • Jenkins Build EC2 Ubuntu
        • Jenkins CI/CD
          • Create a Build Item
          • Create a Build Pipleine
            • Pipeline Using Docker
            • Pipeline Examples
          • Jenkins CI with S3
            • Jenkins CI - S3
          • Jenkins CI with EC2
    • Jenkins CI Cluster Mode
    • AWS Code Pipeline CI/CD
      • AWS CI/CD Tools
        • AWS Code Build
        • AWS Code Deploy to Beanstalk
        • AWS Code Deploy to EC2
        • AWS Pipeline - Example CI/CD
  • Docker
    • Docker
      • Docker for Developers
        • Install and setup
        • Docker Commands
        • Docker Images Container
        • Docker Architecture
    • Docker Demos
      • Node JS Container
    • Docker-compose
      • Using Docker Compose
      • Docker Compose Demo
  • AWS Quick Refresh
    • AWS Quick Recap - Videos
    • AWS Quick Recap
  • AWS Architecture - Lab
    • Application Deployment - 01
    • Application Deployment - 02
    • Application 3 tier Architecture
  • Basic Networking
    • Computer Networking for Beginners
      • Basic of Networking
      • Networking Protocols
      • OSI Model
      • Network address and Host address
      • Subnetting Type
    • Network Architecture
    • Networking Layers OSI Model
    • Internet protocol
      • CIDR and subnetting
        • Examples
      • AWS VPC Subnets
  • VPC and Networking
    • AWS VPC
    • VPC Demo
      • Bastion Host | Jump Server
  • AWS Components
    • AWS Components In Depth
      • AWS Storage
        • AWS EBS
        • AWS Cloudfront
        • AWS S3
      • AWS Compute
        • ECS
        • AWS VPC
          • VPC Components
        • AWS EC2
        • AWS ELB
          • Application Load balancer
            • Example
        • AWS EC2 Auto Scaling
          • Demo
        • AWS Route 53
        • AWS Lambda Serverless
          • AWS Lambda Serverless Computing
  • Assignments
    • Assignment 01-Node JS app on EC2
    • Assignment 02-Node JS with Mysql
    • Assignment-03
  • Microservices
    • Microservices Architecture
      • Docker and Docker-Compose
      • Docker-Compose Example 01
      • Docker-Compose Example 02
      • Hand-on | Building Microservices
    • Architecture Components
  • AWS ECS
    • AWS ECS
      • Introduction of ECS
Powered by GitBook
On this page

Was this helpful?

  1. AWS Architecture - Lab

Application Deployment - 02

PreviousApplication Deployment - 01NextApplication 3 tier Architecture

Last updated 5 years ago

Was this helpful?

Lets Build this Architecture where we are deploying Node JS apps on EC2 instances in different availability Zones

Lets first talk about Load balancers

Let’s start with an example, consider a scenario where you have more than one Ec2 Instances sitting behind a Web Server to serve your application. Now, how can you ensure that the traffic load is equally shared between all the Ec2 Instances to avoid imbalance(as shown in the above figure) ? To meet this need we have ELB i.e. Elastic Load Balancer that helps to load balance incoming application traffic across Amazon EC2 instances in a single Availability Zone or multiple Availability Zones. Let’s create one Elastic Load Balancer.

  1. Classic Load Balancer (CLB) — It does routing decision at Layer 4 of the OSI Model i.e. at TCP Layer. CLB are best in use when routing and load-balancing decisions are based on IP addresses and TCP ports

  2. Application Load Balancer (ALB) — It does routing decision at layer 7 of the OSI Model i.e. at Application Layer. Multiple services can share a single ALB using path-based routing which can be enabled by adding rules for Listeners and multiple target groups. This feature differentiates an ALB from CLB.

Start with creating a Classic Load Balancer first-

Next, set Listener Configuration:-

Load Balancer Protocol and Port — Specify the protocol and port which a user will use to access the Web Server through the Load Balancer. It’s a common practice to keep the LB Protocol and port same as Instance’s Protocol and port

Instance Protocol and Port — Specify the protocol and port number used by our Ec2 Instances to serve the Web Application. For e.g. in my case, My “Hello World” app is running on port 80(HTTP) of the instance so I made the entries as shown below-

Fig 1: CLB Configuration

Next, assign a security group to the ELB keeping in mind the ports you want/don’t want to open for the world.

If you choose HTTP protocol for the Load Balancer in the previous step then you’ll see a warning message indicating that we aren’t using HTTPS, also not using any kind of SSL certificates. We can ignore this message at this point in time because our focus is to understand the working of Load Balancer. Click on Configure Health Check, this is an important step.The Load Balancer will perform health checks on your EC2 instances based on the Ping Protocol, Port and Path provided in this step. I’ll perform a health check on the index.html for this article but keep in mind that you can provide any Ping Protocol, Port and Path which ensures that your ec2 Instance is actively serving the Web Application.

There are also other parameters(described below) to set and in case if you forget what they mean, just scroll over them to see their description( A tip for the exam!)

Response Time — Amount of time the LB is gonna wait for response from health check(2 sec-60 sec).

Interval — Time between two consecutive Health Checks(5 sec — 300 sec)

Unhealthy Threshold — Number of Consecutive health check failures before declaring an Ec2 Instance as being Unhealthy.

Healthy Threshold — Number of Consecutive successful health check before declaring an Ec2 Instance as being healthy. Check the image below for example entries:-

Fig 2: CLB Health Check

Next, move forward to add the Ec2 Instances serving the Web Application to this Load Balancer. ELB provides us with features:-1. Enable Cross-Zone Load Balancing and 2. Enable Connection Draining

Click on Review and Create to create this Load Balancer. Now once the Load Balancer is ready, notice some important points -

  1. The Load Balancer is provided with a DNS name(not public IP) and if everything is working fine then you can see the web application serving at this DNS name.

  2. Go to instances under the Load Balancer section, there are two Instance states-

a. Out Of Service — Instance does not pass health check

b. In Service — Successful health checks are indicated.

3. Once an Ec2 Instance is Out of Service, the Load Balancer will not send traffic to

that unhealthy Instance till the time it becomes healthy again.

This was all about the basics of Classic Load Balancer required for Certification Exam. Let’s move Application Load Balancer.

Fig 3 : Cross-zone load balancing and Availability Zones.

Application Load Balancer (ALB) — Application Load Balancer is very similar to CLB, the main difference is that it does path based routing. For routing to different paths, create a target group for each application and create a different rule for each target group. For example:-

  • Target Group A → Instances 1 and 2, port 8084

  • Target Group B → Instances 1 and 2, port 8086

Then on the ALB, you would create 2 rules for port 80, like so:

  • Path /application1 → Target Group A

  • Path /application2 → Target Group B

ALB Features

  1. Content-Based Routing

  2. Host-based Routing

  3. Path-based Routing

  4. Containerized Application Support with EC2 Container Service

  5. HTTP/2 Support, HTTPS Support

  6. WebSockets Support

  7. Native IPv6 Support

  8. Sticky Sessions

  9. High Availability

Login to AWS Console and ensure you have at least two Ec2 Instances serving any Web Application (as simple as “Hello World :) “) because we will need these instances at a later stage to attach to our ELB. Though it is possible to have a single server behind a load balancer, it is best to have a pool of servers behind an ELB. Under Ec2, go to and click on . AWS provides 2 types of Load Balancers -

Select and Click on continue. Configure your Load Balancer by giving a name. We can create a Load Balancer inside a VPC as per our needs which can restrict the traffic to our web server and provide security.

If you want to read more on this then refer to this

Load Balancers
Create Load Balancer
Classic Load Balancer
link
EC2 instance exposing API using Load balancers