首页 > ATS调优 > 回源流量控制-SRV 测试使用

回源流量控制-SRV 测试使用

2013年4月26日     浏览数:8,110 发表评论 阅读评论

TS-1713 是taobao 针对ats 回源流量控制所针对性的一个patch修复.

主要原理是通过设置DNS的SRV记录,控制记录的优先级和权重,从而达到回源的流量控制。

Ats 在回源的时候依赖于DNS查询。在启用DNS SRV记录支持后,优先查询SRV记录。目前只支持_http._tcp

简单介绍一下SRV的记录格式

srv记录格式如下:
参考:http://www.zytrax.com/books/dns/ch8/srv.html
srvce.prot.name ttl class rr pri weight port target

_http._tcp.www.sina.com.cn. SRV 0 2 80 sina.

优先级数值越小,级别越大。在优先级相同情况下,权重越大,记录出现比例就越大。

费话不多说了,上干货吧。

拿git master中的数据,然后编译安装,如果觉得不方便,就自己build rpm包。

安装后,开启srv 查询支持,把dns解析指向本地的dns,我本地以bind为例。

[php]

traffic_line -s proxy.config.srv_enabled -v 1
traffic_line -s proxy.config.dns.nameservers -v 127.0.0.1
traffic_line -x

[/php]

开启debug

[php]

traffic_line -s proxy.config.diags.debug.enabled -v 1
traffic_line -s proxy.config.diags.debug.tags -v dns*
traffic_line -x

[/php]

remap.config 以sina为例,配置如下:

[php]

map http://www.sina.com.cn/ http://www.sina.com.cn/

[/php]

本地dns 配置zone 如下:

[php]
$TTL 60
$ORIGIN .
@ IN SOA ns1. root.localhost. (
20051213;
7000;
3000;
15000;
86400;
);

@ 86400 IN NS ns1
ns1 86400 IN A 127.0.0.1
sina. A 218.30.66.101 A 218.30.66.102

sina2. A 58.63.236.32
A 58.63.236.36
_http._tcp.www.sina.com.cn. SRV 0 2 80 sina.
SRV 0 1 80 sina2.
;—–
*. IN CNAME wild
*.cn. IN CNAME wild
*.com. IN CNAME wild
*.com.cn. IN CNAME wild
*.gov. IN CNAME wild
*.gov.cn. IN CNAME wild
*.edu. IN CNAME wild
*.edu.cn. IN CNAME wild

[/php]

确保你的named和ats 正常运行

接下来测试

[php]

wget -S -O /dev/null -e http_proxy=127.0.0.1 http://www.sina.com.cn/

[/php]

看一下输出日志吧.别的不再多说了。

[php]

[Apr 3 13:56:50.022] Server {0x2ae95d56c700} DEBUG: (dns_srv) Beginning lookup of SRV records for origin _http._tcp.www.sina.com.cn
[Apr 3 13:56:50.023] Server {0x2ae95d56c700} DEBUG: (dns_srv) delaying (force=0) SRV answer for _http._tcp.www.sina.com.cn [timeout = 0]
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns_srv) SRV lookup of _http._tcp.www.sina.com.cn
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) received query _http._tcp.www.sina.com.cn type = 33, timeout = 0
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns_srv) DNSProcessor::getby attempting an SRV lookup for _http._tcp.www.sina.com.cn, timeout = 0
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) enqueing query _http._tcp.www.sina.com.cn
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) adding first to collapsing queue
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) send query (qtype=33) for _http._tcp.www.sina.com.cn to fd 93
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) sent qname = _http._tcp.www.sina.com.cn, id = 10892, nameserver = 0
[Apr 3 13:56:50.023] Server {0x2ae95bf3f100} DEBUG: (dns) sent_one: failover_number for resolver 0 is 1
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns) received packet size = 189
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns) primary DNS response code = 0
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) Discovered SRV record [from NS lookup] with cost:0 weight:1 port:80 with host:sina2
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) Discovered SRV record [from NS lookup] with cost:0 weight:2 port:80 with host:sina
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns) inserting name = _http._tcp.www.sina.com.cn
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns) SUCCESS result for _http._tcp.www.sina.com.cn = _http._tcp.www.sina.com.cn af=0 retry 0
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns) called back continuation for _http._tcp.www.sina.com.cn
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) inserted SRV RR record [sina2] into HostDB with TTL: 60 seconds
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) inserted SRV RR record [sina] into HostDB with TTL: 60 seconds
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) beginning process_srv_info
[Apr 3 13:56:50.024] Server {0x2ae95bf3f100} DEBUG: (dns_srv) select SRV records sina2
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) received query sina2 type = 1, timeout = 0
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) enqueing query sina2
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) adding first to collapsing queue
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) send query (qtype=1) for sina2 to fd 93
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) sent qname = sina2, id = 8919, nameserver = 0
[Apr 3 13:56:50.044] Server {0x2ae95bf3f100} DEBUG: (dns) sent_one: failover_number for resolver 0 is 1
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) received packet size = 87
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) primary DNS response code = 0
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) received A name = sina2
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) received A = 58.63.236.32
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) received A = 58.63.236.36
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) SUCCESS result for sina2 = 58.63.236.32 retry 0
[Apr 3 13:56:50.045] Server {0x2ae95bf3f100} DEBUG: (dns) called back continuation for sina2

[/php]

Postal code 48125 agency name dearborn heights school district 7 assignment helper county name wayne county highest grade offered 12 total students 824 more info about the school mailing address 4650 clippert street, dearborn heights,mi
分类: ATS调优 标签: ,
  1. 纸鸢
    2013年4月26日01:40 | #1

    引出了新知识点,学习了!

  2. 高高
    2016年5月26日16:48 | #2

    您下载SRV的连接失效了,还请指教,怎样编译安装SRV?

  1. 本文目前尚无任何 trackbacks 和 pingbacks.