写在前面:
前两天一个保险客户火急火燎的找到我说:“涛哥,有部分用户反馈说我们的手机APP用起来有点卡,加载页面缓慢,你帮排查下可能是什么问题?”。然后给我提供了一个加载缓慢那个页面对象的URL。
我们先大概梳理下客户提供的线索:
1. 部分用户有问题(部分这个词就很玄学)
2. 用起来卡、页面加载缓慢(很主观的词)
基于客户提供的线索,我准备先来个敲山震虎,看看能不能把问题点震出来,毕竟我一直信奉,大力出奇迹。
问题分析定位
经过和用户进一步沟通,用户反馈:手机APP在wifi模式下使用基本没问题,但是使用4G网络就就会出现卡、慢的问题,并且使用安卓手机的用户反馈这类卡、慢问题比较多。根据这一重要线索,结合以往趟过的坑总结的经验,基本把问题锁定在DNS解析和IPv6解问题上来。
1. 用户打开手机端APP
2. 手机APP调用外部URL资源渲染页面
3. 移动端发起DNS请求解析URL IP
4. 移动端解析获取到IP地址后开始下载资源
1. 使用dig命令测试该域名解析A记录记录,解析返回正常
➜ dig @223.5.5.5 ecxx.sdns.xxx.com
; <<>> DiG 9.10.6 <<>> @223.5.5.5 ecxx.sdns.xxx.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19170
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;ecxx.sdns.xxx.com. IN A
;; ANSWER SECTION:
ecxx.sdns.xxx.com. 36 IN A 202.127.x.x
;; Query time: 73 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Jul 02 12:29:14 CST 2021
;; MSG SIZE rcvd: 73
复制
2. 使用dig命令测试该域名解析AAAA记录记录,未返回结果
➜ dig @223.5.5.5 ecxx.sdns.xxx.com aaaa
; <<>> DiG 9.10.6 <<>> @223.5.5.5 ecxx.sdns.xxx.com aaaa
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached
复制
wireshark抓取的AAAA解析流程如下,从抓包上看客户端会尝试三次去请求该域名的AAAA记录,但是没有响应,耗时在10s左右。
通过F5 GTM上查看该域名解析配置,由于客户IDC 并没有申请IPv6运营商链路接入,目前GTM域名解析配置只有A记录,没有AAAA记录配置。
那么虽然没有IPv6链路,但是能不能当移动端访问该域名的AAAA记录时,我在F5 GTM设备上直接返回结果,高速移动端不存在该解析记录,不用尝试三次?
接着往下看!
随着运营商IPv6网络如火如荼的建设,正常来说,大部分的有线网络或者移动4G网络的终端可以获取到IPv6的地址,如果客户端获取到IPv6地址时,不管发起访问业务类型是C/S还是B/S业务(假设是通过域名连接),底层系统都会同时发起该域名解析记录的A和AAAA的查询,根据操作系统机制不同可能会优先访问IPv6或者IPv4,对于优先访问IPv6的系统来说,当IPv6解析失败 会回退到IPv4网络访问,但是中间延迟超过了大部分人的忍耐程度,可能在10s以上了。
通过以上分析,我们大概能够推断客户反馈部分移动端访问慢的问题,解决方式就是当移动端发起AAAA记录解析查询时,直接告诉客户端该域名AAAA解析记录不存在,在DNS Response Headder中插入 NO ERROR即可立即结束查询操作,避免后续的两次DNS查询动作。
F5 GTM全局开启针对AAAA记录查询的NO ERROR方式
Using an iRule
Note: This functionality is available only through the use of BIG-IP LTM and DNS iRules; the BIG-IP Link Controller system does not have iRule functionality.
Log in to the Configuration utility.
Go to the iRules list:
For BIG-IP 11.6.x and later, go to DNS > Delivery > iRules.
For BIG-IP 11.5.x and earlier, go to Global Traffic > iRules.
Select Create.
Select a name for the iRule.
In the Definition box, enter the following iRule text:
BIG-IP 12.x and later:
when DNS_REQUEST {
if {[DNS::question type] equals "AAAA" }{
DNS::header rcode NOERROR
DNS::return
}
}
BIG-IP 11.6.x and earlier:
when DNS_REQUEST {
if { [DNS::rrtype] equals "AAAA" } {
noerror
}
}
Select Create.
Add the iRule to the BIG-IP DNS listener.
DNS > Delivery > Listeners > Listener List.
复制
F5 GTM某个域名开启 NO ERROR
Configuring BIG-IP DNS
BIG-IP 12.0.0 and later
Note: In BIG-IP 12.0.0 and later, you must create a type AAAA Wide IP to return a NOERROR response for IPv6 queries. In this procedure, F5 assumes you already have a type A Wide IP created for the fully qualified domain name.
Log in to the Configuration utility.
Go to DNS > GSLB > Wide IPs.
Select Create.
For Name, enter the fully qualified domain name that matches the type A Wide IP for which you want to provide NOERROR responses for IPv6 queries.
For Type, select AAAA wide IP.
For General Properties, select Advanced.
For Return Code On Failure, select Enabled.
For RCODE, select NOERROR (no error).
Optional: For SOA Negative Caching TTL, enter the number of seconds that the local DNS servers consider the IPv6 NoError response to be valid.
Select Update.
The wide IP now returns NOERROR responses to IPv6 AAAA or A6 DNS requests that come to the wide IP.
BIG-IP 11.6.x and earlier
Log in to the Configuration utility.
Go to DNS > GSLB > Wide IPs.
Note: For versions earlier than BIG-IP 11.5.0, go to Global Traffic > Wide IPs.
Select the wide IP for which you want to configure BIG-IP DNS to provide NOERROR responses.
For General Properties, select Advanced.
For IPv6 NOERROR Response, select Enabled.
Optional: For BIG-IP 11.2.1 and later, for IPv6 NoError TTL, enter a TTL value.
Select Update.
The wide IP now returns NOERROR responses to IPv6 AAAA or A6 DNS requests to the wide IP.
复制
开启IPv6 NO ERROR后解析效果
1. 使用dig命令测试该域名解析AAAA记录记录,返回 NO ERROR(可以对比未开启前)
dig @223.5.5.5 ecxx.sdns.xxx.com aaaa
; <<>> DiG 9.10.6 <<>> @223.5.5.5 ecxx.sdns.xxx.com aaaa
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43184
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;www.sdns.gcoxxxxx.cn. IN AAAA
;; Query time: 79 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Fri Jul 02 12:27:57 CST 2021
;; MSG SIZE rcvd: 49
复制
2. wireshark抓包信息如下,查看NO ERROR标志已插入
通过F5 GTM开始IPv6 NO ERROR后进行测试,移动端APP延迟改善明显,正在进一步测试中……
总结
以上分享了一下随着IPv6网络的普及,移动端可能带来的新的问题,希望能给各位铁子们在以后的运维排错中有所启发。
最近一直在渡劫中,好久没输出了内容了,后续陆续给铁子们补上,感谢支持。
参考链接:
https://support.f5.com/csp/article/K7851
觉得本文对你有帮助,请分享给更多人
- EOF -
3、手把手教你使用Rancher快速创建一个kubernetes集群