当前位置:网站首页>除了解析域名,DNS还能干吗?
除了解析域名,DNS还能干吗?
2020-11-09 12:53:00 【osc_fge5j3lp】
一个http请求,典型的执行流程是怎么样的呢?

可以看到,典型流程为:
(1)客户端请求dns-server,发起域名解析;
(2)dns-server返回域名对应的外网ip(1.2.3.4);
(3)客户端通过外网ip(1.2.3.4),访问反向代理;
(4)反向代理通过内网ip(192.168.x.x),将请求分发给web-server;
(5)web-server对请求进行处理;
其中,第一个步骤,将域名转化ip的过程,发生在应用系统的外部,是通过DNS实现的。
除了域名解析,在架构设计时,还能利用DNS做一些什么事情呢?
一、用户就近访问

DNS可以实现,用户所需资源的就近访问:
(1)电信用户想要访问某一个服务器资源;
(2)浏览器向dns-server发起域名解析请求;
(3)dns-server识别出访问者是电信用户;
(4)dns-server将电信机房的nginx外网ip返回给访问者;
(5)访问者就近访问;
根据用户ip来返回最近的服务器ip,称为“智能DNS”,CDN以及多机房多活中最常用。
二、反向代理水平扩展

典型的互联网架构中,可以通过增加web-server来扩充web层的性能,但反向代理nginx仍是整个系统的唯一入口,如果系统吞吐超过nginx的性能极限,难以扩容,此时就需要dns-server来配合水平扩展。
具体做法是:在dns-server对于同一个域名可以配置多个nginx的外网ip,每次DNS解析请求,轮询返回不同的ip,这样就能实现nginx的水平扩展,这个方法叫“DNS轮询”。
三、web-server负载均衡

既然“dns轮询”可以将同一个域名的流量均匀分配到不同的nginx,那么也可以利用它来做web-server的负载均衡:
(1)架构中去掉nginx层;
(2)将多个web-server的内网ip直接改为外网ip;
(3)在dns-server将域名对应的外网ip进行轮询解析;
通过DNS来实施负载均衡有什么优缺点呢?
优点:
(1)利用第三方DNS实施,服务端架构不用动;
(2)少了一层网络请求;
不足:
(1)DNS只具备解析功能,不能保证对应外网ip的可用性,而nginx做反向代理时,与web-server之间有保活探测机制,当web-server挂掉时,能够自动迁移流量;
(2)当web-server需要扩容时,通过DNS扩容生效时间长,而nginx是服务端完全自己可控的部分,web-server扩容更实时更方便;
因为上面两个原因,架构上一般都使用高可用反向代理。
总结
架构设计中,除了域名解析,DNS还有其他用武之地:
(1)智能DNS,根据用户ip来就近访问服务器;
(2)DNS轮询,水平扩展反向代理层;
(3)利用DNS实施负载均衡;
希望大家有收获。
扫码关注“架构师之路”视频号
视频号要有100个关注,才能开通认证,希望大家成为前100个朋友。感谢,感恩。
版权声明
本文为[osc_fge5j3lp]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4417091/blog/4709460
边栏推荐
- 在企业的降本增效诉求下,Cube如何助力科盾业务容器化“一步到位”?
- Mac terminal oh my Zsh + solarized configuration
- Large scale project Objective-C - nsurlsession access SMS verification code application example sharing
- Is multithreading really faster than single threading?
- Interface tests how to pass files in post requests
- 一个简单的能力,决定你是否会学习!
- Four steps of Android integrated payment
- Android studio AVD
- 外贸自建网站域名的选择— Namesilo 域名购买
- In the future, China Telecom will make cloud computing service the main business of China Telecom
猜你喜欢

In the future, China Telecom will make cloud computing service the main business of China Telecom

Android studio import customized framework classess.jar As 4.0.1 version is valid for pro test

块级元素和行内元素

为wget命令设置代理

SQL Chapter 2 Chapter 3

Tidb x micro banking reduces time consumption by 58%, and distributed architecture helps to realize inclusive finance

The choice of domain name of foreign trade self built website

Solve the problem of idea shortcut key Alt + insert invalid

Tutorial system unity online course double 11 preferential registration is in progress

分库分表的 9种分布式主键ID 生成方案,挺全乎的
随机推荐
阿里、腾讯、百度、网易、美团Android面试经验分享,拿到了百度、腾讯offer
Kubernetes business log collection and monitoring
Show profile analysis of SQL statement performance overhead
Learning notes of nodejs
Large scale project Objective-C - nsurlsession access SMS verification code application example sharing
Method of creating flat panel simulator by Android studio
Open source ERP recruitment
Handwriting Koa.js Source code
SQL Chapter 2 Chapter 3
Is multithreading really faster than single threading?
How to use function framework to develop large web application
On the calculation of non interaction polarizability
Three practical skills of Medical Project Management
关于无相互作用极化率的计算
Jsliang job series - 08 - handwritten promise
android studio AIDL的使用
Mac terminal oh my Zsh + solarized configuration
线上服务的FGC问题排查,看这篇就够了!
SEO见风使舵,是对还是错?
JVM learning (5) - execution subsystem