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

智能推荐

oracle 12c 集群安装后的检查_12c查看crs状态-程序员宅基地

文章浏览阅读1.6k次。安装配置gi、安装数据库软件、dbca建库见下:http://blog.csdn.net/kadwf123/article/details/784299611、检查集群节点及状态:[root@rac2 ~]# olsnodes -srac1 Activerac2 Activerac3 Activerac4 Active[root@rac2 ~]_12c查看crs状态

解决jupyter notebook无法找到虚拟环境的问题_jupyter没有pytorch环境-程序员宅基地

文章浏览阅读1.3w次,点赞45次,收藏99次。我个人用的是anaconda3的一个python集成环境,自带jupyter notebook,但在我打开jupyter notebook界面后,却找不到对应的虚拟环境,原来是jupyter notebook只是通用于下载anaconda时自带的环境,其他环境要想使用必须手动下载一些库:1.首先进入到自己创建的虚拟环境(pytorch是虚拟环境的名字)activate pytorch2.在该环境下下载这个库conda install ipykernelconda install nb__jupyter没有pytorch环境

国内安装scoop的保姆教程_scoop-cn-程序员宅基地

文章浏览阅读5.2k次,点赞19次,收藏28次。选择scoop纯属意外,也是无奈,因为电脑用户被锁了管理员权限,所有exe安装程序都无法安装,只可以用绿色软件,最后被我发现scoop,省去了到处下载XXX绿色版的烦恼,当然scoop里需要管理员权限的软件也跟我无缘了(譬如everything)。推荐添加dorado这个bucket镜像,里面很多中文软件,但是部分国外的软件下载地址在github,可能无法下载。以上两个是官方bucket的国内镜像,所有软件建议优先从这里下载。上面可以看到很多bucket以及软件数。如果官网登陆不了可以试一下以下方式。_scoop-cn

Element ui colorpicker在Vue中的使用_vue el-color-picker-程序员宅基地

文章浏览阅读4.5k次,点赞2次,收藏3次。首先要有一个color-picker组件 <el-color-picker v-model="headcolor"></el-color-picker>在data里面data() { return {headcolor: ’ #278add ’ //这里可以选择一个默认的颜色} }然后在你想要改变颜色的地方用v-bind绑定就好了,例如:这里的:sty..._vue el-color-picker

迅为iTOP-4412精英版之烧写内核移植后的镜像_exynos 4412 刷机-程序员宅基地

文章浏览阅读640次。基于芯片日益增长的问题,所以内核开发者们引入了新的方法,就是在内核中只保留函数,而数据则不包含,由用户(应用程序员)自己把数据按照规定的格式编写,并放在约定的地方,为了不占用过多的内存,还要求数据以根精简的方式编写。boot启动时,传参给内核,告诉内核设备树文件和kernel的位置,内核启动时根据地址去找到设备树文件,再利用专用的编译器去反编译dtb文件,将dtb还原成数据结构,以供驱动的函数去调用。firmware是三星的一个固件的设备信息,因为找不到固件,所以内核启动不成功。_exynos 4412 刷机

Linux系统配置jdk_linux配置jdk-程序员宅基地

文章浏览阅读2w次,点赞24次,收藏42次。Linux系统配置jdkLinux学习教程,Linux入门教程(超详细)_linux配置jdk

随便推点

matlab(4):特殊符号的输入_matlab微米怎么输入-程序员宅基地

文章浏览阅读3.3k次,点赞5次,收藏19次。xlabel('\delta');ylabel('AUC');具体符号的对照表参照下图:_matlab微米怎么输入

C语言程序设计-文件(打开与关闭、顺序、二进制读写)-程序员宅基地

文章浏览阅读119次。顺序读写指的是按照文件中数据的顺序进行读取或写入。对于文本文件,可以使用fgets、fputs、fscanf、fprintf等函数进行顺序读写。在C语言中,对文件的操作通常涉及文件的打开、读写以及关闭。文件的打开使用fopen函数,而关闭则使用fclose函数。在C语言中,可以使用fread和fwrite函数进行二进制读写。‍ Biaoge 于2024-03-09 23:51发布 阅读量:7 ️文章类型:【 C语言程序设计 】在C语言中,用于打开文件的函数是____,用于关闭文件的函数是____。

Touchdesigner自学笔记之三_touchdesigner怎么让一个模型跟着鼠标移动-程序员宅基地

文章浏览阅读3.4k次,点赞2次,收藏13次。跟随鼠标移动的粒子以grid(SOP)为partical(SOP)的资源模板,调整后连接【Geo组合+point spirit(MAT)】,在连接【feedback组合】适当调整。影响粒子动态的节点【metaball(SOP)+force(SOP)】添加mouse in(CHOP)鼠标位置到metaball的坐标,实现鼠标影响。..._touchdesigner怎么让一个模型跟着鼠标移动

【附源码】基于java的校园停车场管理系统的设计与实现61m0e9计算机毕设SSM_基于java技术的停车场管理系统实现与设计-程序员宅基地

文章浏览阅读178次。项目运行环境配置:Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。项目技术:Springboot + mybatis + Maven +mysql5.7或8.0+html+css+js等等组成,B/S模式 + Maven管理等等。环境需要1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。_基于java技术的停车场管理系统实现与设计

Android系统播放器MediaPlayer源码分析_android多媒体播放源码分析 时序图-程序员宅基地

文章浏览阅读3.5k次。前言对于MediaPlayer播放器的源码分析内容相对来说比较多,会从Java-&amp;amp;gt;Jni-&amp;amp;gt;C/C++慢慢分析,后面会慢慢更新。另外,博客只作为自己学习记录的一种方式,对于其他的不过多的评论。MediaPlayerDemopublic class MainActivity extends AppCompatActivity implements SurfaceHolder.Cal..._android多媒体播放源码分析 时序图

java 数据结构与算法 ——快速排序法-程序员宅基地

文章浏览阅读2.4k次,点赞41次,收藏13次。java 数据结构与算法 ——快速排序法_快速排序法