はじめに
2023年4月にDatadogの日本リージョンが開設されました。そこで今回はfluent-plugin-datadogを使って各サイト(リージョン)への転送速度を測定してみました。
やること
比較対象は下記のサイトです。
- http-intake.logs.datadoghq.com
- http-intake.logs.us3.datadoghq.com
- http-intake.logs.us5.datadoghq.com
- http-intake.logs.ap1.datadoghq.com
上記の各サイトに対して送信するログの件数を変えて送信にかかる時間を複数回(1000, 5000, 10k)計測します。
結果
結果は以下のようになりました。前半はリハーサルで後半が本番です。
Rehearsal ---------------------------------------------------------------------------------
1000:http-intake.logs.datadoghq.com 0.222123 0.038513 0.271236 ( 3.612488)
1000:http-intake.logs.us3.datadoghq.com 0.221955 0.029407 0.263962 ( 3.020622)
1000:http-intake.logs.us5.datadoghq.com 0.203634 0.027897 0.243245 ( 1.272141)
1000:http-intake.logs.ap1.datadoghq.com 0.236828 0.030862 0.279271 ( 1.304738)
5000:http-intake.logs.datadoghq.com 0.620319 0.076329 0.708515 ( 6.639452)
5000:http-intake.logs.us3.datadoghq.com 0.829551 0.104338 0.950285 ( 4.893020)
5000:http-intake.logs.us5.datadoghq.com 0.688516 0.091656 0.792717 ( 5.729534)
5000:http-intake.logs.ap1.datadoghq.com 0.741620 0.098632 0.855831 ( 3.806363)
10000:http-intake.logs.datadoghq.com 1.208986 0.143448 1.363966 ( 11.145961)
10000:http-intake.logs.us3.datadoghq.com 1.232092 0.149081 1.392651 ( 6.063299)
10000:http-intake.logs.us5.datadoghq.com 1.185103 0.157157 1.354805 ( 9.060065)
10000:http-intake.logs.ap1.datadoghq.com 1.149029 0.148340 1.309812 ( 5.124043)
------------------------------------------------------------------------ total: 9.786296sec
user system total real
1000:http-intake.logs.datadoghq.com 0.196583 0.028067 0.237158 ( 2.707089)
1000:http-intake.logs.us3.datadoghq.com 0.210324 0.030582 0.252644 ( 1.277877)
1000:http-intake.logs.us5.datadoghq.com 0.212724 0.025928 0.250213 ( 1.276817)
1000:http-intake.logs.ap1.datadoghq.com 0.216581 0.029848 0.256965 ( 1.279732)
5000:http-intake.logs.datadoghq.com 0.617097 0.072738 0.701225 ( 6.591118)
5000:http-intake.logs.us3.datadoghq.com 0.623482 0.086100 0.721945 ( 4.596881)
5000:http-intake.logs.us5.datadoghq.com 0.631735 0.082244 0.726973 ( 5.600707)
5000:http-intake.logs.ap1.datadoghq.com 0.631631 0.078744 0.723613 ( 3.598259)
10000:http-intake.logs.datadoghq.com 1.158280 0.141669 1.311219 ( 12.237270)
10000:http-intake.logs.us3.datadoghq.com 1.226229 0.168048 1.407403 ( 6.128550)
10000:http-intake.logs.us5.datadoghq.com 1.203580 0.157624 1.372727 ( 9.072105)
10000:http-intake.logs.ap1.datadoghq.com 1.143689 0.147730 1.303902 ( 5.116522)
※読みづらいですが左からap1,us1,us3,us5です。
考察
いずれの件数でもap1は他のサイトよりも結果がよかったです。特に件数が多い場合に差が大きくなったのでログ転送においてはサイトを変えることによる改善効果が期待できそうです。
参考
スクリプト
ベンチマークスクリプトおよびGemfileは下記です。
require "fluent/plugin/out_datadog"
require "fluent/config"
require "fluent/engine"
require "fluent/log"
require "fluent/log/console_adapter"
require "fluent/test/driver/output"
require "fluent/test/helpers"
require "fluent/test/log"
require "securerandom"
require "benchmark"
include Fluent::Test::Helpers
HOSTS = %w(
http-intake.logs.datadoghq.com
http-intake.logs.us3.datadoghq.com
http-intake.logs.us5.datadoghq.com
http-intake.logs.ap1.datadoghq.com
)
NUM_RECORDS = [1000, 5000, 10000]
def create_driver(conf)
Fluent::Test::Driver::Output.new(Fluent::DatadogOutput).configure(conf)
end
def config(host)
c = Fluent::Config.new
c["api_key"] = ENV["api_key"]
c["host"] = host
c["dd_tags"] = "dd_host:#{host}"
c["include_tag_key"] = true
c["tag_key"] = "tag"
c
end
Benchmark.bmbm(45) do |report|
NUM_RECORDS.each do |r|
HOSTS.each do |host|
report.report("#{r}\t#{host}") {
dd = create_driver(config(host))
dd.run(default_tag: host) do
r.times do
dd.feed(event_time, { "msg" => SecureRandom.uuid * 100 })
end
end
}
end
end
end
Gemfile
gem "fluent-plugin-datadog", "~> 0.14.2"