DNS服务部署的那点事儿之DNS压力测试

#刚才发博文提示大于15万字儿,写不开了,单独开篇博文来补充一下

Bind压力测试

bind有专门的工具可以将配置文件的数据放入到数据库中,对于bind来讲,最常见的压力测试软件是querypery,此工具是bind源码包自带的一个工具,但安装完bind之后很有可能官方的包并没有给我们提供由此我们不得不去自己编译安装它

1.安装queryperf

可以在www.isc.org 下载bind10-1.1.0并安装它们

[root@testtools]# wgethttps://www.isc.org/downloads/file/bind-9-9-4-p1-tar-gz/?version=tar.gz

[root@testtools]# cd bind-9.9.4-P1/contrib/queryperf/

[root@testqueryperf]# make

gcc  -DHAVE_CONFIG_H -c queryperf.c

gcc  -DHAVE_CONFIG_H  queryperf.o -lnsl -lresolv  -lm -o queryperf

#不用直接make install 将queryperf 拷贝至/bin/目录即可

[root@testqueryperf]# cp queryperf /bin/


2.使用queryperf

首先创建文件指定需要测试的域名和记录类型

[root@test~]# cat test.txt

www.test.comA

test.comNS

10.0.10.60PTR

使用-d指定数据文件做压力测试的时候要对其解析哪些记录为基准型测试,-s 指定需要压测的服务器IP

[root@test~]# queryperf -d test.txt -s 10.0.10.60

DNSQuery Performance Testing Tool

Version:$Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $


[Status]Processing input data                 #正在读取数据

[Status]Sending queries (beginning with 10.0.10.60)    #发送查询请求

[Status]Testing complete  


Statistics:


 Parse input file:     once

 Ended due to:         reaching end of file


 Queries sent:         3 queries              #共发起了多少请求

 Queries completed:    3 queries              #完成了多少请求

 Queries lost:         0 queries              #丢失多少请求

 Queries delayed(?):   0 queries        


 RTT max:             0.006557sec             #将请求发出去响应回过来最大的一次耗时多少

 RTT min:              0.002860 sec           #最短一次

 RTT average:          0.004116 sec           #平均多久

 RTT std deviation:    0.001721 sec

 RTT out of range:     0 queries


 Percentage completed: 100.00%                #完成的比例

 Percentage lost:        0.00%                #丢失的比例


 Started at:           Wed Dec 18 20:29:43 2013

 Finished at:          Wed Dec 18 20:29:43 2013

 Ran for:              0.009473 seconds


 Queries per second:   316.689539 qps         #每秒钟平均能完成多少个请求

#之前测试的数量太少,接下来修改test.txt,将信息填满:

www.test.comA

test.comNS

10.0.10.60PTR

test.comMX

10.0.10.61PTR

10.0.10.60PTR

10.0.10.61PTR

10.0.10.60PTR

123.test.comA         #这个域名不存在

mail.test.comA

然后将如上行多复制几行,(不论怎么复制行都可以如下所示

[root@test~]# wc -l test.txt

3774840test.txt

再次进行压力测试

[root@test~]# queryperf -d test.txt -s 10.0.10.60

DNSQuery Performance Testing Tool

Version:$Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $


[Status]Processing input data

[Status]Sending queries (beginning with 10.0.10.60)

[Timeout]Query timed out: msg id 62

[Timeout]Query timed out: msg id 64

[Timeout]Query timed out: msg id 71

[Timeout]Query timed out: msg id 73

[Timeout]Query timed out: msg id 80

[Timeout]Query timed out: msg id 82

[Timeout]Query timed out: msg id 89

[Timeout]Query timed out: msg id 91

[Timeout]Query timed out: msg id 98

[Timeout]Query timed out: msg id 100

[Status]Testing complete


Statistics:


 Parse input file:     once

 Ended due to:         reaching end of file


 Queries sent:         2364 queries

 Queries completed:    2364 queries

 Queries lost:         0 queries

 Queries delayed(?):   0 queries


 RTT max:             0.347522sec

 RTT min:              0.000083 sec

 RTT average:          0.002009 sec

 RTT std deviation:    0.022389 sec

 RTT out of range:     0 queries


 Percentage completed: 100.00%

 Percentage lost:        0.00%


 Started at:           Wed Dec 18 20:40:35 2013

 Finished at:          Wed Dec 18 20:40:40 2013

 Ran for:              5.024620 seconds


 Queries per second:   470.483340 qps


#可以看到以下有很多包处于丢失状态

[Status]Processing input data

[Status]Sending queries (beginning with 10.0.10.60)

[Timeout]Query timed out: msg id 62

[Timeout]Query timed out: msg id 64

[Timeout]Query timed out: msg id 71

[Timeout]Query timed out: msg id 73

[Timeout]Query timed out: msg id 80

#----------略------------------

[Status]Testing complete

但是在本地测试不用考虑服务器端的带宽查看本地服务器负载情况

[root@test~]# uptime

20:51:07 up 2:27,  2 users,  load average: 2.20, 0.00, 0.00

发现利用率也不高使用vmstat查看实时负载情况可以看到阻塞队列正常,bi bo量偶尔会有所以中断和上下文切换量也很小所以这些都不是问题可是响应速度依然非常的慢

[root@test~]# vmstat 1

procs-----------memory---------- ---swap-- -----io---- --system-- -----cpu-----

r b   swpd   free  buff  cache   si  so    bi    bo  in   cs us sy id wa st

0 0      0  68720 53988 214796    0    0   26    15   25  23  0  0 96 3  0    

0 0      0  68712 53988 214800    0    0    0     0   18  20  0  0 100 0  0  

0 0      0  68712 53988 214800    0    0    0     0   19  13  0  0 100 0  0  

0 0      0  68712 53988 214800    0    0    0     0   15  14  0  1 99 0  0    

技术压力测试,切换到其它服务器对其进行压力测试

[root@test~]# queryperf -d test.txt -s 10.0.10.61

依旧如此有一堆的timeout

Warning:RTT is out of range: 29.990839 [query=10.0.10.61/12, rcode=2]

Warning:RTT is out of range: 24.962086 [query=10.0.10.61/12, rcode=2]

Warning:RTT is out of range: 24.962383 [query=10.0.10.61/12, rcode=2]

[Timeout]Query timed out: msg id 223

[Timeout]Query timed out: msg id 224

[Timeout]Query timed out: msg id 212

[Timeout]Query timed out: msg id 193

接下来在被测试的服务器上使用rndcstatus查看named服务器的运行状况

[root@test2~]# rndc status

version:9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6

CPUsfound: 1

workerthreads: 1

numberof zones: 21

debuglevel: 0

xfersrunning: 0

xfersdeferred: 0

soaqueries in progress: 0

querylogging is OFF                  #query log是关闭的

recursiveclients: 20/0/1000         #收到20个递归请求 tcp clien没有

tcpclients: 0/100

serveris up and running

怀疑是否是反向解析的问题,将test.txt包含反向解析的行全部使用sed删除

[root@test~]# sed -i '/^10/d' test.txt  

[root@test~]# queryperf -d test.txt -s 10.0.10.61


DNSQuery Performance Testing Tool

Version:$Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $


[Status]Processing input data

[Status]Sending queries (beginning with 10.0.10.61)

[Timeout]Query timed out: msg id 1

[Timeout]Query timed out: msg id 2

[Timeout]Query timed out: msg id 3

[Timeout]Query timed out: msg id 4

[Timeout]Query timed out: msg id 5

[Timeout]Query timed out: msg id 6

[Timeout]Query timed out: msg id 7

[Timeout]Query timed out: msg id 8

[Timeout]Query timed out: msg id 9


Statistics:


 Parse input file:     once

 Ended due to:         reaching end of file


 Queries sent:         4548 queries

 Queries completed:    4548 queries

 Queries lost:         0 queries

 Queries delayed(?):   0queries


 RTT max:             0.004176sec

 RTT min:              0.000126 sec

 RTT average:          0.001663 sec

 RTT std deviation:    0.000515 sec

 RTT out of range:     0 queries


 Percentage completed: 100.00%

 Percentage lost:        0.00%


 Started at:           Wed Dec 18 20:59:48 2013

 Finished at:          Wed Dec 18 20:59:48 2013

 Ran for:              0.405095 seconds


 Queries per second:   11226.996137 qps           #总共每秒可以承受11226个查询请求

进一步压力测试

可以看到,此服务器负载比刚才高出了一些

[root@test~]# wc -l test.txt

13633842test.txt

[root@test~]# queryperf -d test.txt -s 10.0.10.61

[root@test2~]# vmstat  1

procs-----------memory---------- ---swap-- -----io---- --system-- -----cpu-----

r b   swpd   free  buff  cache   si  so    bi    bo  in   cs us sy id wa st

1 0      0 314332  12800 60260    0    0    2     0 7686   59 25 95 0  0  0    

1 0      0 314332  12800 60260    0    0    0     0 7731   36 30 89 1  0  0    

1 0      0 314332  12800 60260    0    0    0     0 7494   40 36 84 0  0  0

得出结果

DNSQuery Performance Testing Tool

Version:$Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $


[Status]Processing input data

[Status]Sending queries (beginning with 10.0.10.61)

[Status]Testing complete


Statistics:


 Parse input file:     once

 Ended due to:         reaching end of file


 Queries sent:         3774840 queries

 Queries completed:    3774840 queries

 Queries lost:         0 queries

 Queries delayed(?):   0 queries


 RTT max:             0.041022sec

 RTT min:              0.000037 sec

 RTT average:          0.001813 sec

 RTT std deviation:    0.000452 sec

 RTT out of range:     0 queries


 Percentage completed: 100.00%

 Percentage lost:        0.00%


 Started at:           Wed Dec 18 21:04:24 2013

 Finished at:          Wed Dec 18 21:10:16 2013

 Ran for:              351.908312 seconds


 Queries per second:   8726.771353 qps

感兴趣的童鞋,可以将查询日志打开,再次进行压力测试,这里就不做演示了,打开后可以通过iostat 来查看负载情况,每秒读写的数据量多少,很有可能在某个磁盘上不停的写入数据,所以正是因为io子系统比较慢

3.使用dnstop监视bind服务性能状态

使用dnstop来实现观测dns响应请求查询时候的性能

安装dnstop

[root@testdnstop-20121017]# wgethttp://dns.measurement-factory.com/tools/dnstop/src/dnstop-20121017.tar.gz

[root@testdnstop-20121017]# cd dnstop-20121017

[root@testdnstop-20121017]# ./configure

[root@testdnstop-20121017]# make &&  makeinstall

如何使用可以使用man来查看帮助文档 man dnstop 或参考 http://book.51cto.com/art/201108/281821.htm

开始抓包分析,对eth0接口的请求进行分析:

[root@testdnstop-20121017]# dnstop -4 -Q -R eth0

Queries:0 new, 0 total                    Wed Dec 18 21:59:57 2013

Replies:0 new, 0 total


Sources     Count     %   cum%

到10.0.10.61上对其做dig查询

[root@test2tools]# dig -t A www.test.com @10.0.10.60

[root@test2tools]# dig -t A www.test.com @10.0.10.60

再次查看60的监测状态

Queries:0 new, 2 total              

Wed Dec18 22:01:01 2013

Replies:0 new, 2 total


Sources        Count      %  cum%

------------------- ------ ------

10.0.10.61         2 100.0  100.0

可以键1-3对其对类型进行统计比如

com

test.com

www.test.com

总结:

(1)抓包时可以在61上对60进行压力测试观测效果);

(2)建议做压力测试的时候对目标主机做分布式压力测试,效果更佳;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值