DevOps 04 - AWS advanced

Posted by Lanzhou on February 13, 2022

Research summary:

  • Auto Scaling Groups (ASGs)
  • Load Balancers
  • CDNs

Why we need to learn these concepts/services?

1 Auto Scaling Groups

1.1 ASG

Using Auto Scaling to Provide Elasticity

Free

Amazon EC2 Auto Scaling

  • Launches or terminates instances based on specified conditions
  • Automatically registers new instances with load balancers when specified
  • Can launch across Availability Zones

Way to Auto Scale

  • Scheduled
    • Good for predictable workloads
    • Scale based on time or day
    • Use case: Turning off your Dev and Test instances at night
  • Dynamic
    • Excellent for general scaling
    • Supports target tracking
    • Use case: Scaling based on CPU utilization
  • Predictive
    • Easiest to use
    • Machine learning based scaling
    • Use case: No longer need to manually adjust rules

Auto Scaling - Purchasing Options

  • On-Demand Instances
  • Reserved Instances
  • Spot Instances

Auto Scaling Minimum Capacity

Auto Scaling group defines:

  • Desired capacity
  • Minimum capacity
  • Maximum capacity

What would be a good minimum capacity to set it to?

What would be a good maximum capacity to set it to?

Auto Scaling Considerations

  • You might need to combine multiple types of autoscaling
  • Your architecture might require more hands scaling using Step scaling
  • Some architectures need to scale on 2 or more metrics (not just CPU)
  • Try to scale out early and fast, while scaling in slowly over time????
  • Use lifecycle hooks - perform custom actions as Auto Scaling launches or terminates instances
  • Avoid thrashing (aggressive instance termination)

Scale in and scale out??

Scale out - more instances

Scale in - less intances (terminate some instances)

Load Balancers

Elastic Load Balancing (ELB)

A managed load balancing service that distributes incoming application traffic across multiple Amazon EC2 instances, containers, and IP addresses.

  • The idea is traffic distribution as a service.

ELB: Features

  • Use HTTP, HTTPS, TCP and SSL (secure TCP) protocols.
  • Can be external or internal facing
  • Each load balancer is given a DNS name
  • Recognises and responds to unhealthy instances

ELB: Options

Application Load Balancer

HTTP & HTTPS

  • Flexible application management
  • Advanced load balancing of HTTP and HTTPS traffic
  • Operates at the request level (Layer 7)
  • Support content-based routing and applications that run in containers
  • Check the health of their targets (instances or containers)
  • Best used with websites and mobile apps

Network Load Balancer

TCP, TLS, UDP

  • Extreme performance and static IP for your application
  • Load balancing of TCP, TLS, and UDP traffic
  • Operates at the connection level (Layer 4)
  • Ideal for balancing TCP traffic
  • Are optimized to handle sudden and volatile traffic patterns while using a single static IP address per Availability Zone
  • Are designed to handle tens of millions of requests per second while maintaining high throughput at ultra-low latency, with no effort on your part

Classic Load Balancer

  • Existing application that was built within EC2 Classic network
  • Operates at both the request level and connection level
  • Support load balancing across multiple Availability Zones

Why use ELB

  • High availability
  • Health checks
  • Security features
  • TLS termination

Connection Draining

If you need to remove an instance from your production fleet, but don’t want to affect your users:

Affected backend instances will complete requests in progress before deregistration

CDNs

AWS Global Infrastructure

In oreder to deliver contetn to users,Amazon CloudFront uses

  • 10+ Regional Edge Caches
  • 80+ Edge Locations
  • (number increases as well)
  • benefits: lower latency, improve access speed to interact with web apps.
  • e.g. Web server is in Singapore, User in New York. Can use CloudFront to cache content in New York locally.

  • Edge locations
    • locations around the world that they can serve your website from with CloudFront.
    • more than 225 points of presence, in 88 cities across 45 countries.

Amazon CloudFront Overview

CDN → Content Delivery Network

  • Content delivery networks provide a globally-distributed network of proxy servers that cache content. (e.g. web videos, bulky media). → more locally to consumers. → Improve access speed.
  • Amazon CloudFront is a content delivery network operated by AWS.

Characteristics:

  • Global, Growing Network
  • Secure Content at the Edge
  • Deep Integration with Key AWS Services
  • High Performance
  • Cost effective
  • Easy to use

Configure a CDN

  • AWS Console → CloudFront → Create Distribution → Choose type (RTMP for video streaming, Web for usual content delivery) → Set one origin and one behaviour(origin can be S3, or app outside of AWS; Behaviour matches URL patterns you want to associate with that origin)

Use cases

  • Static Asset Caching
  • Live and On-Demand Video Streaming
  • Security and DDoS Protection
  • Dynamic and Customized Content
  • API Acceleration
  • Software Distribution

Whiteboard structure of VPC with brand new concepts

Presentation:

We discussed about the Networking on AWS last week. The next thing we want to talk about is another major benefit of AWS.— Scalability & Elasticity

Or how capacity can grow and shrink based on your business needs

Useful Resources: