Lecture 202: Routing Policy - Weighted
- 课程:[NEW] AWS Certified Advanced Networking Specialty 2026
- 视频时长:05:02
- 来源:Udemy Lecture 28556401
- Slide 数量:6
- 画面切换:00:58、01:36、02:21、03:16、04:05
扫描说明
逐条读取了 Udemy 页面中的 125 条英文 Transcript cue,并按时间轴扫描全长约 05:02 的视频。依据 Weighted 比例机制、规则与用例、首条 Record、其余 Record、控制台与浏览器验证、dig 采样验证划分为 6 个小节。截图均在 Transcript 侧栏关闭、播放器控件隐藏后复核,统一为 1364×770。
Transcript 来自 Udemy 页面自带的英文自动字幕,没有使用 ASR。下面保留页面原文,包括其中的语法或识别错误。
1. Weighted 按相对 Weight 控制 DNS Answer 比例
时间范围:00:00–00:58
总结 / Summary
中文
Weighted Routing 为同一名称的每条 Record 分配相对 Weight,并按 record weight ÷ sum of all weights 计算其被返回的概率。例如 Weight 70、20、10 会形成约 70%、20%、10% 的 DNS Answer 分布。Weight 是相对值,不要求合计为 100。
English
Weighted routing assigns a relative weight to each record for the same name. Its response probability is the record weight divided by the sum of all record weights. Weights of 70, 20, and 10 therefore yield roughly 70%, 20%, and 10% of DNS answers, but weights do not need to total 100.
Transcript
00:00 So now let's talk about
00:01 the weighted routing policy.
00:03 The idea is that you can have a percentage of requests
00:05 you can control to go to a specific resource
00:07 thanks to weights.
00:09 So, put it simply in the diagram,
00:10 we have Amazon route 53,
00:11 and then we have three EC2 instance
00:14 that have been assigned different weights,
00:15 so 70, 20, and 10.
00:17 In my example, these weights sum up to 100,
00:20 but you don't have to in the real life, okay?
00:22 But what this means that 70%
00:23 of the DNS responses from Amazon as on route 53
00:27 are going to be redirecting to the first EC2 instance,
00:30 then 20% to the second and 10% to the third.
00:33 So what we have to do in our weight is to assign each record
00:36 a relative weights.
00:38 And then the traffic percentage is going to be sent
00:40 to each record, as just the weight of the record
00:43 divided by the sum of all the weights of all the records
00:45 which is like a percentage of all the weights, okay?
00:49 The weights don't need to sum up to 100,
00:50 they're just indicative of how much
00:52 we want to send to this instance,
00:54 compared to all the other records in your DNS name.
2. 记录须同名同 Type,可配 Health Check 与渐进式切流
时间范围:00:58–01:36
总结 / Summary
中文
参与 Weighted Set 的 DNS Record 必须具有相同 Name 与 Type,并可各自关联 Health Check。典型用例包括跨 Region Load Balancing、Canary/新版本测试和逐步流量迁移。把某条 Weight 设为 0 会停止向它返回流量;若所有 Record 都为 0,Route 53 会将它们等权处理。
English
Records in a weighted set must share the same name and type, and each can be associated with a health check. Common uses include cross-region load balancing, canary or new-version testing, and gradual traffic shifts. A zero weight suppresses a record, while all-zero records are treated equally.
Transcript
00:58 So to make this work,
00:59 the DNS records must have the same name and type,
01:02 and you can associate them with health checks,
01:04 although we haven't seen with health checks are again yet,
01:06 but we'll have a look at them very, very soon.
01:08 Now the use cases for a weighted routing policy
01:11 is pretty obvious, is to do for example, load balancing,
01:13 maybe across different regions, or to test a new application
01:16 version by sending a small amount of traffic to it,
01:19 and so on.
01:20 And then if you're sending to sort of a weight of zero,
01:22 then you're going to stop sending traffic
01:23 to a specific resource, so you can shift weight over time.
01:26 And if all the resource records will have a weight of zero,
01:29 then all the records will be returned with equal weights.
01:33 So let's have a look in the console
01:34 to see how that works.
3. 创建 Southeast Record:Weight 10、TTL 3 秒
时间范围:01:36–02:21
总结 / Summary
中文
创建 weighted.stephanetheteacher.com 的第一条 A Record,Value 使用 ap-southeast-1 实例 IP,Routing Policy 选 Weighted,Weight 设为 10。演示为了快速观察结果把 TTL 设为 3 秒,并用 Record ID “SOUTHEAST” 标识该 Record;实际生产环境通常不会使用如此短的 TTL。
English
Create the first A record for weighted.stephanetheteacher.com using the ap-southeast-1 instance IP. Select Weighted routing, assign weight 10, use a three-second TTL for demonstration, and label it SOUTHEAST with the record ID. Such a short TTL would generally not be used in production.
Transcript
01:36 So let's create a new record,
01:37 and this one is going to be called
01:39 weighted.stephanethetaccher.com.
01:41 It's an A record, and the routing policy
01:44 is going to be weighted.
01:46 So first for the first value, let's enter the one
01:48 from the ap-southeast-1,
01:51 and the weights I'm going to assign to it
01:53 this time is going to be 10, okay?
01:55 So it's very, very small weights.
01:57 For the TTL, I'm going to set it to something really low,
02:00 three seconds to just show you the impact of weighted.
02:02 But obviously, this is not a TTL
02:03 you would use in real life.
02:05 So as we can see,
02:06 we can associate a health check with it,
02:07 but for now we won't.
02:08 And we have a record ID that we can set.
02:10 And this is to identify this specific record
02:13 within the weighted record sets.
02:15 So for this one, I got this instance from the southeast,
02:18 I'm just going to write southeast.
4. 再创建 US East 70 与 EU 20 两条独立 Record
时间范围:02:21–03:16
总结 / Summary
中文
为相同 Name 与 A Type 再增加两条独立 Record:us-east-1 IP 的 Weight 为 70、Record ID 为 US EAST;eu-central-1 IP 的 Weight 为 20、Record ID 为 EU,TTL 同样为 3 秒。与 Simple 的“一条 Record 含多个 Value”不同,Weighted 必须是多条 Record,每条只有一个 Answer 与自己的 Weight。
English
Add two more independent records with the same name and A type: the us-east-1 IP with weight 70 and record ID US EAST, and the eu-central-1 IP with weight 20 and record ID EU, both using a three-second TTL. Unlike one simple record with multiple values, weighted routing uses separate records, each with one answer and its own weight.
Transcript
02:21 Okay, and then we can add another record.
02:25 And again, we're going to use the same
02:26 weighted.stephanetheteache.com, okay?
02:29 And the routing policy is going to be weighted.
02:32 And the value of which is going to be
02:33 the one from us-east-1.
02:35 So I'm going to copy this IP and paste it here.
02:38 The weight is going to be on this time 70.
02:41 So we're going to send 70% of the traffic to us-east-1,
02:44 and then the record ID is US East.
02:48 Great, and the TTL again, three seconds.
02:50 And one last record we're going to add, so again, weighted,
02:54 and then the value of which is going to be
02:55 eu-central-1, in here.
03:01 And I'm going to send it as a weighted record.
03:03 I'm going to send 20 as weights, and the record ID
03:06 is going to be EU okay.
03:10 And the TTL three seconds.
03:12 So now let's go ahead and create these records.
5. Hosted Zone 显示 10/20/70,浏览器多数命中 US East
时间范围:03:16–04:05
总结 / Summary
中文
创建后,Hosted Zone 中会显示三条同名 A Record,Weight 分别为 10、20、70。浏览器访问 weighted 域名时多数返回 us-east-1a,因为它占总 Weight 的 70%;但短 TTL 到期并重新查询后,也可能命中其他 Region。该比例是长期统计分布,不保证固定次数内精确符合百分比。
English
The hosted zone now lists three same-name A records with weights 10, 20, and 70. Browsing to the weighted hostname most often returns us-east-1a because it owns 70% of the total weight, but a new query after the short TTL may reach another region. The ratio is a long-run distribution, not an exact guarantee over a small number of requests.
Transcript
03:16 And as we can see, we now have three records
03:19 in this table, okay?
03:20 So this is why it's different from, for example,
03:22 a simple record has two values,
03:24 here, we have three records and each record
03:26 has one value as an answer,
03:27 but we have a weight of 10, 20 and 70.
03:31 So if I go to the URL now,
03:33 if I go to weighted.stephanetheteacher.com and press Enter,
03:42 I'm getting a first response from the us-east-1a
03:45 which makes sense because, well,
03:46 this is where 70% of the traffic is supposed to be going
03:49 okay, to this region.
03:52 But if I refresh and I need to refresh
03:54 maybe every three seconds, at some points,
03:57 I should be getting a response from another region.
04:00 And this is just based on weight,
04:01 so this is the (indistinct) behind the weighted resources.
04:03 So as you can see, this one is not changing a lot,
6. 多次 dig 偶尔返回 EU,验证权重是概率而非固定轮询
时间范围:04:05–05:02
总结 / Summary
中文
连续执行 dig weighted.stephanetheteacher.com,通常得到 Weight 70 的 us-east-1 IP,偶尔会返回 Weight 20 的 eu-central-1 IP(3.70.14.253);浏览器也最终显示 eu-central-1c。Weighted 的本质是按权重概率选择 DNS Answer,而不是 Round Robin,也不会让单个 Client 的每次刷新严格按 70/20/10 排列。
English
Repeated dig queries usually return the weight-70 us-east-1 IP but occasionally return the weight-20 eu-central-1 address, 3.70.14.253; the browser also eventually shows eu-central-1c. Weighted routing probabilistically chooses DNS answers rather than performing round robin, and one client's refreshes need not follow an exact 70/20/10 sequence.
Transcript
04:05 so let's do a dig command just to show you
04:08 the output of what it is,
04:09 so dig weighted.stephanetheteacher.com.
04:14 and here we get a TTL of three and the answer is,
04:17 I think still the one from the us-east-1,
04:20 But so let's try to issue one more,
04:22 and see if we get any luckier.
04:25 So the weight of 70 definitely is a big weight.
04:28 Okay, but here as we can see, we just got an answer,
04:31 and this one is a different IP, 3.70.14,
04:34 which is corresponding to the weight of 20.
04:37 So as we can see, weighted does exactly
04:39 what it's supposed to do, it's redirecting
04:40 most of the queries into the one that has the most weight,
04:44 but from time to time, you will get other answers, okay?
04:48 And so on.
04:49 So this is something you can practice in your web browser
04:51 as well as we can see, cool.
04:52 I just get redacted into eu-central-1c.
04:55 So that's it for this lecture,
04:57 and hopefully it shows you the power of weighted records.
04:59 I hope you liked it, and I will see you in the next lecture.
整讲总结 / Overall Summary
中文
Weighted Routing 用多条同名同 Type 的独立 Record 及相对 Weight,按概率控制 DNS Answer 分布。它支持 Health Check,适合跨 Region 分流、Canary 与渐进式迁移;比例是长期统计结果,TTL 与客户端缓存会影响观察。
English
Weighted routing uses separate same-name, same-type records and relative weights to control the probability distribution of DNS answers. It supports health checks and suits cross-region distribution, canary releases, and gradual migrations; observed results are statistical and affected by TTL and client caching.
返回顶部 ↑