This article will talk about the most popular architecture in AWS. Even though docker and k8s those container technologies are popular, some traditional companies may not use it. In fact, there is a transition for traditional company from old technology to new technology. Despite that they try cloud, they still use VM based technology. Based on the VM technology, AWS provides a solution with load balancing, auto scaling and cloud watch to increase the elasticity. Previously, I had done a demonstration for this architecture.
Elastic Load Balancing (ELB)
Elastic load balancing (ELB) distributes traffic across multiple EC2 instances in multiple AZs. It also supports health checks to detect unhealthy EC2 instances. In addition, it supports the routing and load balancing of HTTP, HTTPS, SSL, and TCP traffic to EC2 instances.
There are 3 types of load balancers in AWS.
1. Application Load Balancer
An Application Load Balancer functions at the application layer, the seventh layer of the Open Systems Interconnection (OSI) model. After the load balancer receives a request, it evaluates the listener rules in priority order to determine which rule to apply, and then selects a target from the target group for the rule action. It is suitable for load balancing HTTP and HTTPS traffic.
2. Network Load Balancer
A Network Load Balancer functions at the fourth layer of the Open Systems Interconnection (OSI) model. It can handle millions of requests per second. After the load balancer receives a connection request, it selects a target from the target group for the default rule. It is suitable for ultra-high performance, TLS offloading at scale, centralized certificate deployment, support for UDP, and static IP addresses for your application.
3. Classic Load Balancer
A Classic Load Balancer is the legacy Elastic Load Balancer. It distributes incoming application traffic across multiple EC2 instances in multiple Availability Zones. This increases the fault tolerance of your applications. Elastic Load Balancing detects unhealthy instances and routes traffic only to healthy instances. It is suitable for an existing application running in the EC2-Classic network.
|Feature||Application Load Balancer||Network Load Balancer||Classic Load Balancer|
|Protocols||HTTP, HTTPS||TCP, UDP, TLS||TCP, SSL/TLS, HTTP, HTTPS|
|Connection draining (deregistration delay)||✔||✔||✔|
|Load Balancing to multiple ports on the same instance||✔||✔|
|IP addresses as targets||✔||✔|
|Load balancer deletion protection||✔||✔|
|Configurable idle connection timeout||✔||✔|
|Cross-zone load balancing||✔||✔||✔|
|Elastic IP address||✔|
|Preserve Source IP address||✔|
|Resource-based IAM Permissions||✔||✔||✔|
|Tag-based IAM permissions||✔||✔|
|PrivateLink Support||✔ (TCP, TLS)|
|Source IP address CIDR-based routing||✔|
|Lambda functions as targets||✔|
|HTTP header-based routing||✔|
|HTTP method-based routing||✔|
|Query string parameter-based routing||✔|
|Server Name Indication (SNI)||✔||✔|
|Back-end server encryption||✔||✔||✔|
|Custom Security Policy||✔|
The above table briefly shows the difference between these 3 types of load balancer.
CloudWatch is a monitoring service for AWS cloud resources and the applications we run on AWS. It is visibility into resource utilization, operational performance, and overall demand patterns. Also, it can custom application-specific metrics of our own. And finally it is accessible via AWS management console, APIs, SDK or CLI.
We always use CloudWatch to monitor other AWS resources by graphics and statistics. Also, we could set alarms to trigger notification.
Auto scaling is a service to scale our EC2 capacity automatically. It is well-suited for applications that experience variability in usage. And it is available at no additional charge. By using auto scaling, we will have better fault tolerance, better availability and better cost management.
When we use auto scaling, we have to prepare a launch configuration to launch EC2 instances. It includes AMI ID, instance type, key pair, security groups, block device mapping and user data.
Auto scaling groups contain a collection of EC2 instances that share similar characteristics. Instances in an auto scaling group are treated as a logical grouping for the purpose of instance scaling and management. We can also create a scaling policy that uses CloudWatch alarms to determine when our auto scaling group should scale out or in.
AWS Trusted Advisor
Trusted advisor is a best practice and recommendation engine. It provides AWS customers with performance and security recommendations in four categories: cost optimization, security, fault tolerance and performance improvement.
Auto Scaling helps us ensure that we have the correct number of EC2 instances available to handle the load for our application. We use Amazon CloudWatch alarms with an auto scaling policy to determine when our auto scaling group should scale out or in. Also, we need to choose a load balancer which is suitable for us. Finally, AWS trusted advisor provides best practice and recommendation to us.