Help us understand the problem. What is going on with this article?

dnsperfを使ってPowerDNSの負荷テストを行う

More than 1 year has passed since last update.

目的

dnsperfを使ってPowerDNSの負荷テストを行う

環境

  • CentOS7.4
  • pdns-recursor-4.1.4
  • pdns-4.1.4-1pdns.el7.x86_64
  • Percona-XtraDB-Cluster-server-57

事前準備

レコード追加用のスクリプト作成

以下のスクリプトでテスト用のレコードを1万個作成します。
例ではすでに satsutaba.rich というzoneができている前提です。
スクリプト内のcontentX-API-Key は自分で設定した値を入れてください。

#!/bin/bash
for i in `seq 1 10000`; do
    echo ${i}
    curl -X PATCH --data '{"rrsets": [ {"name": "'"$i"'.satsutaba.rich.", "type": "A", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "DNSサーバのIPアドレス", "disabled": false } ] } ] }' -H 'X-API-Key: hogehoge' http://127.0.0.1:8081/api/v1/servers/localhost/zones/satsutaba.rich.
done

APIについては、こちら を参照

テスト用レコードの作成

query.txt という名前でテスト用レコードを作成しました。
レコード名 レコードタイプ という書式です。
私の場合は、スプレッドシートをゴニョゴニョして作成しました。

# 例)
$ head -n 5 query.txt
1.satsutaba.rich. a
2.satsutaba.rich. a
3.satsutaba.rich. a
4.satsutaba.rich. a
5.satsutaba.rich. a
$ cat query.txt | wc -l
10000
$ 

インストール

$ wget http://li.nux.ro/download/nux/dextop/el7/x86_64/dnsperf-2.1.0.0-2.el7.nux.x86_64.rpm
$ sudo yum localinstall dnsperf-2.1.0.0-2.el7.nux.x86_64.rpm
$ dnsperf -h
DNS Performance Testing Tool
Nominum Version 2.1.0.0

Usage: dnsperf [-f family] [-s server_addr] [-p port] [-a local_addr]
               [-x local_port] [-d datafile] [-c clients] [-T threads]
               [-n maxruns] [-l timelimit] [-b buffer_size] [-t timeout]
               [-e] [-D] [-y [alg:]name:secret] [-q num_queries]
               [-Q max_qps] [-S stats_interval] [-u] [-v] [-h]
  -f address family of DNS transport, inet or inet6 (default: any)
  -s the server to query (default: 127.0.0.1)
  -p the port on which to query the server (default: 53)
  -a the local address from which to send queries
  -x the local port from which to send queries (default: 0)
  -d the input data file (default: stdin)
  -c the number of clients to act as
  -T the number of threads to run
  -n run through input at most N times
  -l run for at most this many seconds
  -b socket send/receive buffer size in kilobytes
  -t the timeout for query completion in seconds (default: 5)
  -e enable EDNS 0
  -D set the DNSSEC OK bit (implies EDNS)
  -y the TSIG algorithm, name and secret
  -q the maximum number of queries outstanding (default: 100)
  -Q limit the number of queries per second
  -S print qps statistics every N seconds
  -u send dynamic updates instead of queries
  -v verbose: report each query to stdout
  -h print this help

負荷テスト

1万レコードでアクセスします。その他は、特にオプションは指定していないのでデフォルト値です。

1回目

dnsperf -s 10.26.5.154 -d query.txt
DNS Performance Testing Tool
Nominum Version 2.1.0.0

[Status] Command line: dnsperf -s 10.26.5.154 -d query.txt
[Status] Sending queries (to 10.26.5.154)
[Status] Started at: Fri Nov 16 12:45:36 2018
[Status] Stopping after 1 run through file
[Status] Testing complete (end of file)

Statistics:

  Queries sent:         10000
  Queries completed:    10000 (100.00%)
  Queries lost:         0 (0.00%)

  Response codes:       SERVFAIL 1393 (13.93%), NXDOMAIN 8607 (86.07%)
  Average packet size:  request 36, response 91
  Run time (s):         87.560025
  Queries per second:   114.207368

  Average Latency (s):  0.855651 (min 0.003303, max 3.559506)
  Latency StdDev (s):   1.081224

$

2回目

$ dnsperf -s 10.26.5.154 -d query.txt
DNS Performance Testing Tool
Nominum Version 2.1.0.0

[Status] Command line: dnsperf -s 10.26.5.154 -d query.txt
[Status] Sending queries (to 10.26.5.154)
[Status] Started at: Fri Nov 16 14:25:03 2018
[Status] Stopping after 1 run through file
[Status] Testing complete (end of file)

Statistics:

  Queries sent:         10000
  Queries completed:    10000 (100.00%)
  Queries lost:         0 (0.00%)

  Response codes:       SERVFAIL 3 (0.03%), NXDOMAIN 9997 (99.97%)
  Average packet size:  request 36, response 99
  Run time (s):         24.607356
  Queries per second:   406.382547

  Average Latency (s):  0.232167 (min 0.071320, max 3.233772)
  Latency StdDev (s):   0.364396

$

2回目は、Queries per second が約4倍になってますね。
キャッシュが効いたものと思われます。

おしまい

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away