AWS助理架构师认证培训 | High Availability and Scalability ELB & ASG_aws stepscaling vs targettrackingscaling-程序员宅基地

技术标签: 数据库  aws  云计算  

视频来源:B站《AWS 认证解决方案架构师 助理级 SAA-C03》

一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!

附上汇总贴:AWS助理架构师认证培训 | 汇总_热爱编程的通信人的博客-程序员宅基地


High Availability and Scalability

Scalability & High Availability

  • Scalability means that an application / system can handle greater loads by adapting
  • There are two kinds of scalability:Vertical ScalabilityHorizontal Scalability (= elasticity)
  • Scalability is linked but different to High Availability
  • Let's deep dive into the distinction, using a call center as an example

Vertical Scalability

  • Vertically scalability means increasing the size of the instance
  • For example, your application runs on a t2.micro
  • Scaling that application vertically means running it on a t2.large
  • Vertical scalability is very common for non distributed systems, such as a database
  • RDS, ElastiCache are services that can scale vertically
  • There's usually a limit to how much you can vertically scale (hardware limit)

Horizontal Scalability

  • Horizontal Scalability means increasing the number of instances / systems for your application
  • Horizontal scaling implies distributed systems
  • This is very common for web applications / modern applications
  • It's easy to horizontally scale thanks the cloud offerings such as Amazon EC2

High Availability

  • High Availability usually goes hand in hand with horizontal scaling
  • High availability means running your application / system in at least 2 data centers (==Availability Zones)
  • The goal of high availability is to survive a data center loss
  • The high availability can be passive (for RDS Multi AZ for example)
  • The high availability can be active (for horizontal scaling)

High Availability & Scalability For EC2

  • Vertical Scaling: Increase instance size (= scale up / down)From: t2.nano - 0.5G of RAM, 1 vCPUTo: u-12tb1.metal - 12.3TB of RAM, 448vCPUs
  • Horizontal Scaling: Increase number of instances (= scale out / in)Auto Scaling GroupLoad Balancer
  • High Availability: Run instances for the same application across multi AZ Auto Scaling Group multi AZLoad Balancer multi AZ

Elastic Load Balancing (ELB) Overview

What is load balancing?

  • Load Balances are servers that forward traffic to multiple servers (e.g., EC2 instances) downstream

Why use a load balancer?

  • Spread load across multiple downstream instances
  • Expose a single point of access (DNS) to your application
  • Seamlessly handle failures of downstream instances
  • Do regular health checks to your instances
  • Provide SSL termination (HTTPS) for your websites
  • Enforce stickiness with cookies
  • High availability across zones
  • Separate public traffic from private traffic

Why use an Elastic Load Balance?

  • An Elastic Load Balancer is a managed load balancerAWS guarantees that it will be workingAWS takes care of upgrades, maintenance, high availabilityAWS provides only a few configuration knobs
  • It costs less to setup your own load balancer but it will be a lot more effort on your end
  • It is integrated with many AWS offerings / services EC2, EC2 Auto Scaling Groups, Amazon ECS AWS Certificate Manager (ACM), Cloud Watch Route 53, AWS WAF, AWS Global Accelerator

Health Checks

  • Health Checks are crucial for Load Balancers
  • They enable the load balancer to know if instances it forwards traffic to are available to reply to requests
  • The health check is done on a port and a route (/health is common)
  • lf the response is not 200 (OK), then the instance is unhealthy

Types of load balancer on AWS

  • AWS has 4 kinds of managed Load Balancers
  • Classic Load Balancer (v1 - old generation) - 2009 - CLB HTTP, HTTPS, TCP, SSL (secure TCP)
  • Application Load Balancer (v2 - new generation) - 2016 - ALBHTTP, HTTPS, Web Socket
  • Network Load Balancer (v2 - new generation) - 2017 - NLB TCP, TLS (secure TCP), UDP
  • Gateway LoadBalancer - 2020 - GWLBOperates at layer 3 (Network layer) - IP Protocol
  • Overal, it is recommended to use the newer generation load balancers as they provide more features
  • Some load balancers can be setup as internal (private) or external (public) ELBs

Load Balancer Security Groups

Classic Load Balancer (CLB)

Classic Load Balancers (v1)

Application Load Balancer (ALB)

Application Load Balancer (v2)

  • Application load balancers is Layer 7 (HTTP)
  • Load balancing to multiple HTTP applications across machines (target groups)
  • Load balancing to multiple applications on the same machine (ex: containers)
  • Support for HTTP/2 and WebSocket
  • Support redirects (from HTTP to HTTPS for example)
  • Routing tables to different target groups:Routing based on path in URL (http://example.com/users & http://example.com/posts)Routing based on hostname in URL (http://one.example.com & http://other.example.com)Routing based on Query String, Headers (http://example.com/users?id=l23&order=false)
  • ALB are a great fit for micro services & container-based application (example: Docker & Amazon ECS)
  • Has a port mapping feature to redirect to a dynamic port in ECS
  • In comparison, we'd need multiple Classic Load Balancer per application

Application Load Balancer (v2) HTTP Based Traffic

Application Load Balancer (v2) Target Groups

  • EC2 instances (can be managed by an Auto Scaling G Group) - HTTP
  • ECS tasks (managed by ECS itself) - HTTP
  • Lambda functions - HTTP request is translated into a JSON event
  • IP Addresses - must be private IPs
  • ALB can route to multiple target groups
  • Health checks are at the target group level

Application Load Balancer (v2) Query Strings/Parameters Routing

Application Load Balancer (v2) Good to Know

  • Fixed hostname (http://XXX.region.elb.amazonaws.com)
  • The application servers don't see the IP of the client directly The true IP of the client is inserted in the header X-Forwarded-For We can also get Port (X-Forwarded-Port) and proto (X-Forwarded-Proto)

Network Load Balancer (NLB)

Network Load Balancer (v2)

  • Network load balancers (Layer4) allow to:Forward TCP & UDP traffic to your instances Handle millions of request per secondsLess latency ~ 100ms (vs 400 ms for ALB)
  • NLB has one static IP per AZ, and supports assigning Elastic IP (helpful for whitelisting specific IP)
  • NLB are used for extreme performance, TCP or UDP traffic
  • Not included in the AWS free tier

Network Load Balancer (v2) TCP (Layer 4) Based Traffic

Network Load Balancer - Target Groups

  • EC2 instances
  • IP Addresses - must be private IPs
  • Application Load Balancer
  • Health Checks support the TCP, HTTP and HTTPS Protocols

Gateway Load Balancer (GWLB)

Gateway Load Balancer

  • Deploy, scale, and manage a fleet of 3rd party network virtual appliances in AWS
  • Example: Firewalls, Intrusion Detection and Prevention Systems, Deep Packet Inspection Systems, payload manipulation, ...
  • Operates at Layer 3 (Network Layer) - IP Packets
  • Combines the following functions:Transparent Network Gateway - single entry/exit for all trafficLoad Balancer - distributes traffic to your virtual appliances
  • Uses the GENEVE protocol on port 6081

Gateway Load Balancer - Target Groups

  • EC2 instances
  • IP Addresses - must be private IPs

Elastic Load Balancer - Sticky Sessions

Sticky Sessions (Session Affinity)

  • It is possible to implement stickiness so that the same client is always redirected to the same instance behind a load balancer
  • This works for Classic Load Balancers & Application Load Balancers
  • The "cookie" used for stickiness has an expiration date you control
  • Usecase: make sure the user doesn't Iose his session data
  • Enabling stickiness may bring imbalance to the load over the backend EC 2 instances

Sticky Sessions - Cookie Names

  • Application-based Cookies Custom cookieGenerated by the targetCan include any custom attributes required by the application Cookie name must be specified individually for each target groupDon't use AWSALB, AWSALBAPP, or AWSALBTG (reserved for use by the ELB)Application cookieGenerated by the load balancer 、Cookie name is AWSALBAPP
  • Duration-based CookiesCookie generated by the load balancer Cookie name is AWSALB for ALB, AWSELB for CLB

Elastic Load Balancer - Cross Zone Load Balancing

Cross-Zone Load Balancing

Cross-Zone Load Balancing

  • Application Load Balancer Always on (can't be disabled)No charges for inter AZ data
  • Network Load BalancerDisabled by defaultYou pay charges ($) for inter AZ data if enabled
  • Classic Load BalancerDisabled by default No charges for inter AZ data if enabled

Elastic Load Balancer - SSL Certificates

SSL/TLS - Basics

  • An SSL Certificate allows traffic between your clients and your load balancer to be encrypted in transit (in-flight encryption)
  • SSL refers to Secure Sockets Layer, used to encrypt connections
  • TLS refers to Transport Layer Security, which is a newer version
  • Nowadays, TLS certificates are mainly used, but people still refer as SSL
  • Public SSL certificates are issued by Certificate Authorities (CA)
  • Comodo, Symantec, GoDaddy, GlobalSign, Digicert, Letsencrypt, etc...
  • SSL certificates have an expiration date (you set) and must be renewed

Load Balancer - SSL Certificates

  • The load balancer uses an X.509 certificate (SSL/TLS server certifcate)
  • You can manage certificates using ACM (AWS Certificate Manager)
  • You can create upload your own certificates alternatively
  • HTTPS listener:You must specify a default certificateYou can add an optional list of certs to support multiple domainsClients can use SNI (Server Name Indication) to specify the hostname they reach Ability to specify a security policy to support older versions of SSL/TLS (legacy clients)

SSL - Server Name Indication

  • SNI solves the problem of loading multiple SSL certificates onto one web server (to serve multiple websites)
  • It's a "newer" protocol, and requires the client to indicate the hostname of the target server in the initial SSL handshake
  • The server will then find the correct certificate, or return the default one

Note:

  • Only works for ALB & NLB (newer generation), Cloud Front
  • Does not work for CLB(older gen)

Elastic Load Balancers - SSL Certificates

  • Classic Load Balancer (v1)Support only one SSL certificate Must use multiple CLB for multiple hostname with multiple SSL certificates
  • Application Load Balancer (v2)Supports multiple listeners with multiple SSL certificates Uses Server Name Indication (SNI) to make it work
  • Network Load Balancer (v2)Supports multiple listeners with multiple SSL certificatesUses Server Name Indication (SNI) to make it work

Elastic Load Balancer - Connection Draining

Connection Draining

  • Feature namingConnection Draining - for CLBDeregistration Delay - for ALB & NLB
  • Time to complete "in-light requests" while the instance is de-registering or unhealthy
  • Stops sending new requests to the EC2 instance which is de-registering
  • Between 1 to 3600 seconds (default: 300 seconds)
  • Can be disabled (set value to 0)
  • Set to a low value if your requests are short

Auto Scaling Groups (ASG) Overview

What's an Auto Scaling Group?

  • In real-life, the load on your websites and application can change
  • In the cloud, you can create and get rid of servers very quickly
  • The goal of an Auto Scaling Group (ASG) is to:Scale out (add EC2 instances) to match an increased loadScale in (remove EC2 instances) to match a decreased loadEnsure we have a minimum and a maximum number of EC2 instances running Automatically register new instances to a load balancerRe-create an EC2 instance in case a previous one is terminated (ex: if unhealthy)
  • ASG are free (you only pay for the underlying EC2 instances)

Auto Scaling Group in AWS

Auto Scaling Group in AWS With Load Balancer

Auto Scaling Scaling Group Attributes

  • A Launch Template (older "Launch Configurations" are deprecated)AMI + Instance TypeEC2 User Data EBS VolumesSecurity GroupsSSH Key PairIAM Roles for your EC2 InstancesNetwork + Subnets InformationLoad Balancer Information
  • Min Size / Max Size / Initial Capacity
  • Scaling Policies

Auto Scaling - CloudWatch Alarms & Scaling

  • lt is possible to scale an ASG based on CloudWatch alarms
  • An alarm monitors a metric (such as Average CPU, or a custom metric)
  • Metrics such as Average CPU are computed for the overall ASG instances
  • Based on the alarm:We can create scale-out policies (increase the number of instances)We can create scale-in policies (decrease the number of instances)

Auto Scaling Groups - Scaling Policies

Auto Scaling Groups - Dynamic Scaling Policies

  • Target Tracking ScalingMost simple and easy to set-up Example: I want the average ASG CPU to stay at around 40%
  • Simple / Step ScalingWhen a CloudWatch alarm is triggered (example CPU > 70%), then add 2 unitsWhen a CloudWatch alarm is triggered (example CPU < 30%), then remove 1
  • Scheduled Actions Anticipate a scaling based on known usage patterns Example: increase the min capacity to 10 at 5 pm on Fridays

Auto Scaling Groups - Predictive Scaling

  • Predictive scaling: continuously forecast load and schedule scaling ahead

Good metrics to scale on

  • CPUUtilization: Average CPU utilization across your instances
  • RequestCountPerTarget: to make sure the number of requests per EC2 instances is stable
  • Average Network In / Out (if you're application is network bound)
  • Any custom metric (that you push using CloudWatch)

Auto Scaling Groups - Scaling Cooldowns

  • After a scaling activity happens, you are in the cooldown period (default 300 seconds)
  • During the cooldown period, the ASG will not launch or terminate additional instances (to allow for metrics to stabilize)
  • Advice: Use a ready-to-use AMI to reduce configuration time in order to be serving request faster and reduce the cooldown period

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/guolianggsta/article/details/131890429

智能推荐

攻防世界_难度8_happy_puzzle_攻防世界困难模式攻略图文-程序员宅基地

文章浏览阅读645次。这个肯定是末尾的IDAT了,因为IDAT必须要满了才会开始一下个IDAT,这个明显就是末尾的IDAT了。,对应下面的create_head()代码。,对应下面的create_tail()代码。不要考虑爆破,我已经试了一下,太多情况了。题目来源:UNCTF。_攻防世界困难模式攻略图文

达梦数据库的导出(备份)、导入_达梦数据库导入导出-程序员宅基地

文章浏览阅读2.9k次,点赞3次,收藏10次。偶尔会用到,记录、分享。1. 数据库导出1.1 切换到dmdba用户su - dmdba1.2 进入达梦数据库安装路径的bin目录,执行导库操作  导出语句:./dexp cwy_init/[email protected]:5236 file=cwy_init.dmp log=cwy_init_exp.log 注释:   cwy_init/init_123..._达梦数据库导入导出

js引入kindeditor富文本编辑器的使用_kindeditor.js-程序员宅基地

文章浏览阅读1.9k次。1. 在官网上下载KindEditor文件,可以删掉不需要要到的jsp,asp,asp.net和php文件夹。接着把文件夹放到项目文件目录下。2. 修改html文件,在页面引入js文件:<script type="text/javascript" src="./kindeditor/kindeditor-all.js"></script><script type="text/javascript" src="./kindeditor/lang/zh-CN.js"_kindeditor.js

STM32学习过程记录11——基于STM32G431CBU6硬件SPI+DMA的高效WS2812B控制方法-程序员宅基地

文章浏览阅读2.3k次,点赞6次,收藏14次。SPI的详情简介不必赘述。假设我们通过SPI发送0xAA,我们的数据线就会变为10101010,通过修改不同的内容,即可修改SPI中0和1的持续时间。比如0xF0即为前半周期为高电平,后半周期为低电平的状态。在SPI的通信模式中,CPHA配置会影响该实验,下图展示了不同采样位置的SPI时序图[1]。CPOL = 0,CPHA = 1:CLK空闲状态 = 低电平,数据在下降沿采样,并在上升沿移出CPOL = 0,CPHA = 0:CLK空闲状态 = 低电平,数据在上升沿采样,并在下降沿移出。_stm32g431cbu6

计算机网络-数据链路层_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输-程序员宅基地

文章浏览阅读1.2k次,点赞2次,收藏8次。数据链路层习题自测问题1.数据链路(即逻辑链路)与链路(即物理链路)有何区别?“电路接通了”与”数据链路接通了”的区别何在?2.数据链路层中的链路控制包括哪些功能?试讨论数据链路层做成可靠的链路层有哪些优点和缺点。3.网络适配器的作用是什么?网络适配器工作在哪一层?4.数据链路层的三个基本问题(帧定界、透明传输和差错检测)为什么都必须加以解决?5.如果在数据链路层不进行帧定界,会发生什么问题?6.PPP协议的主要特点是什么?为什么PPP不使用帧的编号?PPP适用于什么情况?为什么PPP协议不_接收方收到链路层数据后,使用crc检验后,余数为0,说明链路层的传输时可靠传输

软件测试工程师移民加拿大_无证移民,未受过软件工程师的教育(第1部分)-程序员宅基地

文章浏览阅读587次。软件测试工程师移民加拿大 无证移民,未受过软件工程师的教育(第1部分) (Undocumented Immigrant With No Education to Software Engineer(Part 1))Before I start, I want you to please bear with me on the way I write, I have very little gen...

随便推点

Thinkpad X250 secure boot failed 启动失败问题解决_安装完系统提示secureboot failure-程序员宅基地

文章浏览阅读304次。Thinkpad X250笔记本电脑,装的是FreeBSD,进入BIOS修改虚拟化配置(其后可能是误设置了安全开机),保存退出后系统无法启动,显示:secure boot failed ,把自己惊出一身冷汗,因为这台笔记本刚好还没开始做备份.....根据错误提示,到bios里面去找相关配置,在Security里面找到了Secure Boot选项,发现果然被设置为Enabled,将其修改为Disabled ,再开机,终于正常启动了。_安装完系统提示secureboot failure

C++如何做字符串分割(5种方法)_c++ 字符串分割-程序员宅基地

文章浏览阅读10w+次,点赞93次,收藏352次。1、用strtok函数进行字符串分割原型: char *strtok(char *str, const char *delim);功能:分解字符串为一组字符串。参数说明:str为要分解的字符串,delim为分隔符字符串。返回值:从str开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。其它:strtok函数线程不安全,可以使用strtok_r替代。示例://借助strtok实现split#include <string.h>#include <stdio.h&_c++ 字符串分割

2013第四届蓝桥杯 C/C++本科A组 真题答案解析_2013年第四届c a组蓝桥杯省赛真题解答-程序员宅基地

文章浏览阅读2.3k次。1 .高斯日记 大数学家高斯有个好习惯:无论如何都要记日记。他的日记有个与众不同的地方,他从不注明年月日,而是用一个整数代替,比如:4210后来人们知道,那个整数就是日期,它表示那一天是高斯出生后的第几天。这或许也是个好习惯,它时时刻刻提醒着主人:日子又过去一天,还有多少时光可以用于浪费呢?高斯出生于:1777年4月30日。在高斯发现的一个重要定理的日记_2013年第四届c a组蓝桥杯省赛真题解答

基于供需算法优化的核极限学习机(KELM)分类算法-程序员宅基地

文章浏览阅读851次,点赞17次,收藏22次。摘要:本文利用供需算法对核极限学习机(KELM)进行优化,并用于分类。

metasploitable2渗透测试_metasploitable2怎么进入-程序员宅基地

文章浏览阅读1.1k次。一、系统弱密码登录1、在kali上执行命令行telnet 192.168.26.1292、Login和password都输入msfadmin3、登录成功,进入系统4、测试如下:二、MySQL弱密码登录:1、在kali上执行mysql –h 192.168.26.129 –u root2、登录成功,进入MySQL系统3、测试效果:三、PostgreSQL弱密码登录1、在Kali上执行psql -h 192.168.26.129 –U post..._metasploitable2怎么进入

Python学习之路:从入门到精通的指南_python人工智能开发从入门到精通pdf-程序员宅基地

文章浏览阅读257次。本文将为初学者提供Python学习的详细指南,从Python的历史、基础语法和数据类型到面向对象编程、模块和库的使用。通过本文,您将能够掌握Python编程的核心概念,为今后的编程学习和实践打下坚实基础。_python人工智能开发从入门到精通pdf

推荐文章

热门文章

相关标签