這兩天為了測試 DNS server 的 System capacity, 才發現原來還有 "queryperf" 這個小工具,這是 Bind9 內帶的工具,不過我找了一下,雖然我在一開始裝機時就將 Bind9 的相關 package 都安裝了,不過似乎還是沒找到 "queryperf" 的 command...不過沒關係,找不到就直接裝吧...
首先看一下今天的測試環境,這裡有兩台 DNS server,中間都是 2G channel bonding 的網路:
Master DNS server : RHEL 5.2 (bind-9.3.4-6.P1)
Slave DNS server : RHEL 5.1 (bind-9.3.3-7)
首先我們先到 ISC -- Internet Systems Consortium 的 ftp 站 http://ftp.isc.org/isc/bind9/ 去抓 Bind9 Tarbal file : (找自己需要的版本就好)
/opt/querytest_list.txt >> 裡面有 1032 筆 record
/opt/querytest_list2.txt >> 裡面有 519120 筆 record
至於指令的用法也很簡單,就是 "./queryperf -s hostname -d test_file",其中 hostname 是被測試的 DNS server IP address 或 hostname,至於 test_file 就是剛剛編輯的 RR file 囉。
建議是直接裝在 Slave 的機器上,去測試 Master 的機器比較不影響效能,雖然我試完發現差異不太大。這裡我直接示範在 Master server 上跑 queryperf 的結果:
先測試 query 1000 筆 record 的結果:
------------------------------------------------------------------------------------
2010/03/31 補充資料:
再查了一下資料發現其實 Bind9 內建的小工具應該是 dnsperf/resperf 才對,用法跟 queryperf 幾乎一樣,有興趣可以參考一下下面的網頁:
Linux Certif - Man dnsperf(1)
Linux Certif - Man resperf(1)
這裡附上一個測試結果以供比較:
首先看一下今天的測試環境,這裡有兩台 DNS server,中間都是 2G channel bonding 的網路:
Master DNS server : RHEL 5.2 (bind-9.3.4-6.P1)
Slave DNS server : RHEL 5.1 (bind-9.3.3-7)
首先我們先到 ISC -- Internet Systems Consortium 的 ftp 站 http://ftp.isc.org/isc/bind9/ 去抓 Bind9 Tarbal file : (找自己需要的版本就好)
[root@ns1 opt]# wget http://ftp.isc.org/isc/bind9/9.3.4-P1/bind-9.3.4-P1.tar.gz抓回來之後,這裡我們擺在 /opt 底下,然後解壓縮 :
--16:58:53-- http://ftp.isc.org/isc/bind9/9.3.4-P1/bind-9.3.4-P1.tar.gz
Resolving ftp.isc.org... 204.152.184.110, 2001:4f8:0:2::18
Connecting to ftp.isc.org|204.152.184.110|:80...
[root@ns2 opt]# wget http://ftp.isc.org/isc/bind9/9.3.3/bind-9.3.3.tar.gz
--16:56:54-- http://ftp.isc.org/isc/bind9/9.3.3/bind-9.3.3.tar.gz
Resolving ftp.isc.org... 204.152.184.110, 2001:4f8:0:2::18
Connecting to ftp.isc.org|204.152.184.110|:80...
[root@ns1 opt]# tar -zxvf bind-9.3.4-P1.tar.gz接著我們到 /opt/bind-9.3.4-P1/contrib/queryperf/ 目錄下,這裡就是放 queryperf 的位置。
[root@ns2 opt]# tar -zxvf bind-9.3.3.tar.gz
[root@ns1 opt]# cd bind-9.3.4-P1/contrib/queryperf/再來是 "sh configure" 以及 "make" 來編譯我們要的 queryperf 指令:
[root@ns1 queryperf]# sh configure
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for library containing res_mkquery... -lresolv
checking for socket in -lsocket... no
checking for inet_ntoa in -lnsl... yes
checking for gethostbyname2... yes
checking for getaddrinfo... yes
checking for getnameinfo... yes
checking for socklen_t... yes
checking for sa_len... no
configure: creating ./config.status
config.status: creating Makefile
[root@ns1 queryperf]# make接著就可以看到產生了一個新的檔案 "queryperf",這就是我們等一下要用到的指令了。
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_GETHOSTBYNAME2=1 -DHAVE_GETADDRINFO=1 -DHAVE_GETNAMEINFO=1 -c queryperf.c
gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DHAVE_LIBNSL=1 -DHAVE_GETHOSTBYNAME2=1 -DHAVE_GETADDRINFO=1 -DHAVE_GETNAMEINFO=1 queryperf.o -lnsl -lresolv -lm -o queryperf
[root@ns1 queryperf]#
[root@ns1 queryperf]# ls -alrtREADME 檔案裡面有簡介如何使用,當然也可以用 -h 來秀一下 useage:
total 292
-rw-rw-r-- 1 10132 wheel 2981 Jul 12 2001 README
-rw-rw-r-- 1 10132 wheel 1831 May 13 2004 configure.in
-rwxrwxr-x 1 10132 wheel 97865 May 13 2004 configure
-rw-rw-r-- 1 10132 wheel 603 Jul 20 2004 Makefile.in
-rw-rw-r-- 1 10132 wheel 50279 Jan 5 2006 queryperf.c
drwxrwxr-x 2 10132 wheel 4096 Jun 28 2007 utils
drwxrwxr-x 2 10132 wheel 4096 Mar 30 17:29 missing
drwxrwxr-x 2 10132 wheel 4096 Mar 30 17:29 input
drwxrwxr-x 11 10132 wheel 4096 Mar 30 17:29 ..
-rw-r--r-- 1 root root 791 Mar 30 17:30 Makefile
-rwxr-xr-x 1 root root 19302 Mar 30 17:30 config.status
-rw-r--r-- 1 root root 8188 Mar 30 17:30 config.log
-rw-r--r-- 1 root root 34692 Mar 30 17:30 queryperf.o
-rwxr-xr-x 1 root root 34059 Mar 30 17:30 queryperf
drwxrwxr-x 5 10132 wheel 4096 Mar 30 17:30 .
[root@ns1 queryperf]# /opt/bind-9.3.4-P1/contrib/queryperf/queryperf -h使用上主要有兩個步驟,第一就是先建立一個 RR 測試檔案,裡面的格式也很簡單,就是:
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.1.1.2.2.5.4.4 2006/01/05 02:06:09 marka Exp $
Usage: queryperf [-d datafile] [-s server_addr] [-p port] [-q num_queries]
[-b bufsize] [-t timeout] [-n] [-l limit] [-f family] [-1]
[-i interval] [-r arraysize] [-u unit] [-H histfile]
[-T qps] [-e] [-D] [-c] [-v] [-h]
-d specifies the input data file (default: stdin)
-s sets the server to query (default: 127.0.0.1)
-p sets the port on which to query the server (default: 53)
-q specifies the maximum number of queries outstanding (default: 20)
-t specifies the timeout for query completion in seconds (default: 5)
-n causes configuration changes to be ignored
-l specifies how a limit for how long to run tests in seconds (no default)
-1 run through input only once (default: multiple iff limit given)
-b set input/output buffer size in kilobytes (default: 32 k)
-i specifies interval of intermediate outputs in seconds (default: 0=none)
-f specify address family of DNS transport, inet or inet6 (default: any)
-r set RTT statistics array size (default: 50000)
-u set RTT statistics time unit in usec (default: 100)
-H specifies RTT histogram data file (default: none)
-T specify the target qps (default: 0=unspecified)
-e enable EDNS 0
-D set the DNSSEC OK bit (implies EDNS)
-c print the number of packets with each rcode
-v verbose: report the RCODE of each response on stdout
-h print this usage
aaa.com NS這裡我先建兩個含我內部所有 RR record 的測試檔案:
bbb.com MX
ccc.com A
/opt/querytest_list.txt >> 裡面有 1032 筆 record
/opt/querytest_list2.txt >> 裡面有 519120 筆 record
至於指令的用法也很簡單,就是 "./queryperf -s hostname -d test_file",其中 hostname 是被測試的 DNS server IP address 或 hostname,至於 test_file 就是剛剛編輯的 RR file 囉。
建議是直接裝在 Slave 的機器上,去測試 Master 的機器比較不影響效能,雖然我試完發現差異不太大。這裡我直接示範在 Master server 上跑 queryperf 的結果:
先測試 query 1000 筆 record 的結果:
[root@ns1 named]# /opt/bind-9.3.4-P1/contrib/queryperf/queryperf -s localhost -d /opt/querytest_list.txt再先測試 query 519120 筆 record 的結果:
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.1.1.2.2.5.4.4 2006/01/05 02:06:09 marka Exp $
[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 1030 queries
Queries completed: 1030 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.001296 sec
RTT min: 0.000073 sec
RTT average: 0.000344 sec
RTT std deviation: 0.000116 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Wed Mar 30 20:35:04 2010
Finished at: Wed Mar 30 20:35:04 2010
Ran for: 0.020277 seconds
Queries per second: 50796.468906 qps
[root@ns1 named]#
[root@ns1 named]# /opt/bind-9.3.4-P1/contrib/queryperf/queryperf -s localhost -d /opt/querytest_list2.txt最後是在 Slave server 上跑 queryperf 去測試 Master server,先測試 query 1000 筆 record 的結果:
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.1.1.2.2.5.4.4 2006/01/05 02:06:09 marka Exp $
[Status] Processing input data
[Status] Sending queries (beginning with 127.0.0.1)
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 519120 queries
Queries completed: 519120 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.002820 sec
RTT min: 0.000042 sec
RTT average: 0.000382 sec
RTT std deviation: 0.000085 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Wed Mar 30 20:36:31 2010
Finished at: Wed Mar 30 20:36:41 2010
Ran for: 10.158483 seconds
Queries per second: 51102.118299 qps
[root@ns1 named]#
[root@ns2 slaves]# /opt/bind-9.3.3/contrib/queryperf/queryperf -s ns1 -d /opt/querytest_list.txt再先測試 query 519120 筆 record 的結果:
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.1.1.2.2.5.4.4 2006/01/05 02:06:09 marka Exp $
[Status] Processing input data
[Status] Sending queries (beginning with xx.xx.xx.1)
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 1030 queries
Queries completed: 1030 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.000572 sec
RTT min: 0.000128 sec
RTT average: 0.000339 sec
RTT std deviation: 0.000049 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Wed Mar 30 20:42:17 2010
Finished at: Wed Mar 3 20:42:17 2010
Ran for: 0.018820 seconds
Queries per second: 54729.011690 qps
[root@ns2 slaves]#
[root@ns2 slaves]# /opt/bind-9.3.3/contrib/queryperf/queryperf -s ns1 -d /opt/querytest_list2.txt這裡我將 Master DNS server 的 IP 馬賽克起來了...由上面的結果可以看的出來,在這一台機器上的每秒最大查詢數量大約在 5萬6千筆左右,以上,報告完畢。
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.1.1.2.2.5.4.4 2006/01/05 02:06:09 marka Exp $
[Status] Processing input data
[Status] Sending queries (beginning with xx.xx.xx.1)
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 519120 queries
Queries completed: 519120 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.000818 sec
RTT min: 0.000059 sec
RTT average: 0.000330 sec
RTT std deviation: 0.000044 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Wed Mar 30 20:42:51 2010
Finished at: Wed Mar 30 20:43:00 2010
Ran for: 9.113103 seconds
Queries per second: 56964.131756 qps
[root@ns2 slaves]#
------------------------------------------------------------------------------------
2010/03/31 補充資料:
再查了一下資料發現其實 Bind9 內建的小工具應該是 dnsperf/resperf 才對,用法跟 queryperf 幾乎一樣,有興趣可以參考一下下面的網頁:
Linux Certif - Man dnsperf(1)
Linux Certif - Man resperf(1)
這裡附上一個測試結果以供比較:
[root@ns2 slaves]# /usr/local/nom/bin/dnsperf -s ns1 -d /opt/querytest_list2.txt補充完畢~ (詳全文...)
DNS Performance Testing Tool
Nominum Version 1.0.1.0
[Status] Processing input data
[Status] Sending queries (to 113.21.80.1)
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 519120 queries
Queries completed: 519120 queries
Queries lost: 0 queries
Avg request size: 52 bytes
Avg response size: 136 bytes
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Wed Mar 31 14:59:03 2010
Finished at: Wed Mar 31 14:59:13 2010
Ran for: 9.362073 seconds
Queries per second: 55449.257873 qps
[root@ns2 slaves]#