2013年12月22日日曜日

オブジェクトストレージのベンチマークツール、COSBench

AWS Advent Calenderの12月22日分です。

COPSBenchとは

世の中、ベンチマークソフトウェアであふれています。その目的は様々ですが、S3に代表されるオブジェクトストレージのベンチマークソフトウェアは、POSIXなファイルシステムのベンチマークとちがってほとんど普及していません。

Amazon S3のパフォーマンスをあげるコツという記事にあるとおり、S3は使い方によってパフォーマンスが異なります。そのため、実際のワークロードを模擬することで初めて意味のある性能指標を得ることが出来ます。

COSBenchは万能ではありませんが、様々なワークロードをXMLで記述することで、模擬実行できるApache2ライセンスのソフトです。Intelの中国の方を中心に開発がすすめられています。http://www.slideshare.net/ben_duyujie/cosbench-apac に概要があるので、時間があるかた、興味のあるかたはこちらをご覧ください。

構成は、Controllerが複数のDriverに対して測定対象に負荷をかけるように指令する作りです。

つかってみる

本記事では、そのごちゃごちゃした話はさておき、COSBenchを使って、結果を得るところまでみてみることにしましょう。

下準備

cosbenchはubuntu12.03 LTSがメインサポートなので、まずはubuntsu12.03を用意します。

$ sudo apt-get update && sudo apt-get install openjdk-7-jre unzip curl

$ java -showversion
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
.(以下略)

という具合で、openjdkがはいればOKです。

入手とインストール

入手先はgithub上にあります。

$ wget https://github.com/intel-cloud/cosbench/releases/download/0.3.3.0/0.3.3.0.zip
$ unzip 0.3.3.0.zip
$ ln -s 0.3.3.0 cos
$ cd cos
$ chmod +x *.sh

展開した結果は

とりあえず動作確認

まずは、start-allをしてみます。

私の場合は、Vagrantfileをポートフォワードするように修正したので、いったん、vagrant haltしてから、vagrant upします。

~/playground/vagrant-place/ubuntu1204$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 19088 => 19088 (adapter 1)
[default] -- 18088 => 18088 (adapter 1)

ここまでくれば、ポートが動いているかどうかをcurlかなにかで試します。

動いていれば、ワークロードファイルを登録してみます。

vagrant@vagrant-ubuntu:~/cos$ sh cli.sh submit conf/workload-config.xml
Accepted with ID: w1
vagrant@vagrant-ubuntu:~/cos$ sh cli.sh info
Drivers:
driver1 http://127.0.0.1:18088/driver
Total: 1 drivers

Active Workloads:
w1 Sun Dec 22 03:22:03 BRST 2013 PROCESSING
Total: 1 active workloads

さらに、http://127.0.0.1:19088/controller/index.html にアクセスしてみる。

Active Workloadsにw1がみえているはずなので、適当にいじってみるといいです。

sh stop-all.sh で停止します。

実際に使ってみる

Controllerの設定を確認する。

Controllerの設定はcontroller.confで行います。中身は一目瞭然かと。
そして、制御対象のdriverのURLも忘れずに。

vagrant@vagrant-ubuntu:~/cos$ cat conf/controller.conf
[controller]
drivers = 1
loglevel = INFO
logfile = log/system.log
archive_dir = archive

[driver1]
name = driver1
url = http://127.0.0.1:18088/driver

はDriverを動かす

Controllerを動かす前に、Driverを動かします。start-driver.shを走らせるだけ。

vagrant@vagrant-ubuntu:~/cos$ sh start-driver.sh
Launching osgi framwork ...
Successfully launched osgi framework!
Booting cosbench driver ...
.
Starting cosbench-log0.3.3.0 [OK]
Starting cosbench-tomcat0.3.3.0 [OK]
Starting cosbench-config0.3.3.0 [OK]
Starting cosbench-http0.3.3.0 [OK]
Starting cosbench-core0.3.3.0 [OK]
Starting cosbench-core-web0.3.3.0 [OK]
Starting cosbench-api0.3.3.0 [OK]
Starting cosbench-mock0.3.3.0 [OK]
Starting cosbench-ampli0.3.3.0 [OK]
Starting cosbench-swift0.3.3.0 [OK]
Starting cosbench-keystone0.3.3.0 [OK]
Starting cosbench-s30.3.3.0 [OK]
Starting cosbench-librados0.3.3.0 [OK]
Starting cosbench-scality0.3.3.0 [OK]
Starting cosbench-driver0.3.3.0 [OK]
Starting cosbench-driver-web0.3.3.0 [OK]
Successfully started cosbench driver!
Listening on port 0.0.0.0/0.0.0.0:18089 ...
Persistence bundle starting...

Persistence bundle started.
!!! Service will listen on web port: 18088 !!!

というようになれば、OKです。

http://127.0.0.1:18088/driver/index.html にアクセスします。
つくりたてのほやほやなので何も登録はありませんが。。

続いてControllerの起動

これも start-controller.shでOKです。

vagrant@vagrant-ubuntu:~/cos$ sh start-controller.sh
Launching osgi framwork ...
Successfully launched osgi framework!
Booting cosbench controller ...
.
Starting cosbench-log0.3.3.0 [OK]
Starting cosbench-tomcat0.3.3.0 [OK]
Starting cosbench-config0.3.3.0 [OK]
Starting cosbench-core0.3.3.0 [OK]
Starting cosbench-core-web0.3.3.0 [OK]
Starting cosbench-controller0.3.3.0 [OK]
Starting cosbench-controller-web_0.3.3.0 [OK]
Successfully started cosbench controller!
Listening on port 0.0.0.0/0.0.0.0:19089 ...
Persistence bundle starting...

Persistence bundle started.
!!! Service will listen on web port: 19088 !!!

http://127.0.0.1:19088/controller/index.html にアクセスすると、

矢印の先に、submit new workloadsとありますが、ここから負荷ルールファイルを登録します。

これは、オレゴンのS3に対して、64KBのファイルを複数回、80%readでのテストしてみるときのルールです。cprefix= には該当のバケットを指定します。

あとは結果を待つ!

ルールを登録すると、すぐに測定が始まります。数分後には次のような結果をみることになるでしょう。

Final Result

General Report

Op-TypeOp-CountByte-CountAvg-ResTimeThroughputBandwidthSucc-Ratio
init-write0 ops0 BN/A0 op/s0 B/SN/A
prepare-write20 ops1.28 MB772.45 ms1.29 op/s82.76 KB/S100%
read177 ops11.33 MB1042.37 ms6.07 op/s388.55 KB/S100%
write41 ops2.62 MB1180.12 ms1.41 op/s90.2 KB/S100%
cleanup-delete40 ops0 B365.75 ms2.73 op/s0 B/S100%
dispose-delete0 ops0 BN/A0 op/s0 B/SN/A

ResTime (RT) Details

Op-Type60%-RT80%-RT90%-RT95%-RT99%-RT100%-RT
init-writeN/AN/AN/AN/AN/AN/A
prepare-write< 710 ms< 720 ms< 730 ms< 1,490 ms< 1,490 ms< 1,520 ms
read< 1,480 ms< 1,490 ms< 1,510 ms< 1,620 ms< 2,360 ms< 2,760 ms
write< 1,510 ms< 1,540 ms< 1,550 ms< 1,560 ms< 1,580 ms< 1,580 ms
cleanup-delete< 340 ms< 340 ms< 340 ms< 370 ms< 920 ms< 1,020 ms
dispose-deleteN/AN/AN/AN/AN/AN/A

 
となったので、次にアイルランドでも試してみる。

General Report

Op-TypeOp-CountByte-CountAvg-ResTimeThroughputBandwidthSucc-Ratio
init-write0 ops0 BN/A0 op/s0 B/SN/A
prepare-write20 ops1.28 MB1031.1 ms0.97 op/s62.07 KB/S100%
read308 ops19.71 MB376.57 ms10.48 op/s670.73 KB/S100%
write71 ops4.54 MB1686.62 ms2.4 op/s153.9 KB/S100%
cleanup-delete40 ops0 B346.02 ms2.89 op/s0 B/S100%
dispose-delete0 ops0 BN/A0 op/s0 B/SN/A

ResTime (RT) Details

Op-Type60%-RT80%-RT90%-RT95%-RT99%-RT100%-RT
init-writeN/AN/AN/AN/AN/AN/A
prepare-write< 890 ms< 900 ms< 930 ms< 2,390 ms< 2,390 ms< 2,470 ms
read< 310 ms< 320 ms< 330 ms< 900 ms< 1,690 ms< 2,110 ms
write< 1,640 ms< 2,430 ms< 2,720 ms< 3,060 ms< 3,360 ms< 3,400 ms
cleanup-delete< 300 ms< 310 ms< 310 ms< 330 ms< 1,360 ms< 1,480 ms
dispose-deleteN/AN/AN/AN/AN/AN/A

ついでに東京も。

ID: w6 Name: s3-tokyo Current Statefinished
Submitted At: 2013/12/22 4:39:57 Started At: 2013/12/22 4:39:57 Stopped At: 2013/12/22 4:41:00
more info
Final Result
General Report

Op-TypeOp-CountByte-CountAvg-ResTimeThroughputBandwidthSucc-Ratio
init-write0 ops0 BN/A0 op/s0 B/SN/A
prepare-write20 ops1.28 MB88.95 ms11.22 op/s718.29 KB/S100%
read2.83 kops181.06 MB53.83 ms94.52 op/s6.05 MB/S99.93%
write702 ops44.93 MB122.86 ms23.45 op/s1.5 MB/S100%
cleanup-delete40 ops0 B29.45 ms33.87 op/s0 B/S100%
dispose-delete0 ops0 BN/A0 op/s0 B/SN/A

ResTime (RT) Details

Op-Type60%-RT80%-RT90%-RT95%-RT99%-RT100%-RT
init-writeN/AN/AN/AN/AN/AN/A
prepare-write< 90 ms< 100 ms< 120 ms< 130 ms< 130 ms< 130 ms
read< 50 ms< 60 ms< 70 ms< 80 ms< 250 ms< 2,390 ms
write< 120 ms< 140 ms< 160 ms< 190 ms< 280 ms< 1,140 ms
cleanup-delete< 30 ms< 30 ms< 40 ms< 60 ms< 80 ms< 90 ms
dispose-deleteN/AN/AN/AN/AN/AN/A

おわりに

「パフォーマンス計測」という意味で「ベンチマーク」という言葉が使われる事自体に違和感を感じるのは私だけでしょうか。ベンチマークは比較の対象があってはじめてベンチマークであるはずなのですが、巷では比較対象がなくてもその言葉が使われることが多いようです。

本記事では巷で使われる「ベンチマーク」のほうがキャッチーで、ググラビリティ高いためにこの言葉を使いました。

2013年12月17日火曜日

2013年のAWSアップデートを料理にたとえるという難題へのチャレンジ。

2013.12にCookpadで行われたクラウド女子会。2013年のAWSアップデート10個を料理にたとえてみました。

異論、反論があることは承知しておりますので、ぜひご意見ください。

「俺ならもっとカッコイイたとえするぜ」というシリーズもいいかもしれません。


2013年12月5日木曜日

OpsWorksで動かすルールをvagrant+chef soloを使ってローカルでも試せるようにする

 

OpsWorksで動かすルールをvagrant+chef soloを使ってローカルでも試したい!
と思いませんか?

OpsWorksそれ自体はお金はかからないとはいえ、OpsWorksから起動されるec2と付随するいくつかのサービスにはお金がかかります。それを vagrant を使ってローカルで試行錯誤できればお金はかかりません。

OpsWorksはchefで作られていることは周知の事実です。
http://docs.aws.amazon.com/opsworks/latest/userguide/welcome.html にも以下の通り書かれています。

AWS OpsWorks uses its own Chef recipes to configure the instances on a stack. Chef Solo runs on every instance, and AWS OpsWorks sends commands to each instance to run recipes that set up, configure, and shut down the instance. You can extend these actions with your own custom recipes. You can also run your custom recipes on a specific instance or on all instances in your stack.

というわけで、ちょっとやってみましょう。

chefむけにかかれたルールはgitで管理するのが、よくある楽な方法です。そのため、一番ラクなのは「全てのシステム記述を一つのgitに書く」こと。
全てのシステム記述を同じgitに書いていれば、chef soloをopsworksの代わりに使うことでほぼテストはローカルでできる。

と、言いたいところですが、OpsWorksのGUIで設定する部分と、chef soloむけの設定には差異があるので、ちょっとしたコツが必要になります。

  1. ec2の代わりとしてvagrantの中でUbuntuを動作するようにする。
  2. OpsWorks代わりのchef solo環境をlocalに用意する
  3. 設定(site-coolbooks)はbitbucketに配置する

ここでのポイントは、手元につくったChef SoloはあくまでもOpsWorks代わりをさせるためであり、手元のChefSoloには最低限の設定ですませること。

ちなみに、bitbucketは無料でも秘密レポジトリを作れるので、OpsWorksむけにはgithubよりも楽だと思います。

これから書くことはこんなかんじ。OpsWorksの進化はきっととまらないので、今の時点での私のおすすめってことで!

vagrantのインストール

vagrantは
http://downloads.vagrantup.com/
から、自分の環境にあったものをインストール。

昔はRubyGemをつかってインストールしていたが、今は違うので素直にパッケージを使うべきでしょう。

boxでubuntuを用意

vagrant box コマンドをキメる

$ sudo vagrant box add ubuntu-1204-server  http://goo.gl/8kWkm

initしてログインしてみる

問題なくログインできるはず。

$ vagrant init ubuntu-1204-server
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'ubuntu-1204-server'…

$ vagrant ssh
Welcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-32-generic x86_64)

ここまでできてればひとまずOK。

vagrant ssh-configの出力を .ssh/configに登録し、vagrant-ubuntuという名前でログイン可能にする

vagrant ssh-config すると、ラップしている情報を確認できるので、.ssh/configにつっこむ。ここでは hostパラメータvagrant-ubuntu という名前で登録しておく。

後で
ssh vagrant-ubuntu でログインできればOK。

Chef Solo環境の用意

install

どんな方法でもOKだと思う。

$ sudo gem install chef chef-solo

あたりでOK。

Chef SoloでOpsWorks代わりのレポジトリ作り

ここでのポイントは、手元につくったChef SoloはあくまでもOpsWorks代わりをさせるためであり、手元のChefSoloには最低限の設定ですませること。

まずは手元にchef soloの環境を作る。ここではcdn-dns-v2という名前。
これが大本のchef soloであり、

$ knife solo init cdn-dns-v2

つくったディレクトリに移動して

rm -rf site-cookbooks/

いったんgit登録。して、commit.

git add .
git status
git commit

設定(site-coolbooks)の用意

手元のChefSoloとOpsWorksの両方で共通で使う設定(site-cookbooks)は
bitbucketに配置させる。

まずは site-cookbooks作り。

共通で使う設定 であるため、可能な限りこのsite-cookbooksに詰め込むことになる。

knife cookbook create dnsbalance -o dnsbalance
** Creating cookbook dnsbalance
** Creating README for cookbook: dnsbalance
** Creating CHANGELOG for cookbook: dnsbalance
** Creating metadata for cookbook: dnsbalance

$ tree
.
└── dnsbalance
└── dnsbalance
├── CHANGELOG.md
├── README.md
├── attributes
├── definitions
├── files
│ └── default
├── libraries
├── metadata.rb
├── providers
├── recipes
│ └── default.rb
├── resources
└── templates
└── default

12 directories, 4 files

dnsbalance/dnsbalanceと、二段に深くなったディレクトリ構成だが、これはそういうもんだと諦めることにする。

共通で使う設定 であるため、可能な限りこのsite-cookbooksに詰め込むと

$ tree
.
└── dnsblance
├── .git/config (ここは略)
└── dnsbalance
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── metadata.rb
├── recipes
│ └── default.rb
└── templates
└── default
├── dns_balance.sbin.erb
├── init.erb
├── ssh-config.erb
├── td-agent.conf.erb
└── td-agent.conf.erb~

という具合になる。このレポジトリをbitbucketに追加する。

bitbucketに登録

追加の仕方はいろいろだが、
git remote add origin ssh://git@bitbucket.org/ar1/chef-cookbook-dnsbalance.git
といった具合。このときの .git/configを抜粋すると

[remote "origin"]
url = ssh://git@bitbucket.org/ar1/chef-cookbook-dnsbalance.git
fetch = +refs/heads/*:refs/remotes/origin/*

親レポジトリのサブモジュールとして追加

親レポジトリ(OpsWorksの代理として動作するレポジトリ)のディレクトリに移動。
そこのトップで、
submoduleとして、追加する。

git submodule add git@bitbucket.org:ar1/chef-cookbook-dnsbalance.git site-cookbooks

その結果

$ tree
.
├── Berksfile
├── Berksfile.lock
├── cookbooks
├── data_bags
├── nodes
│ └── vagrant-ubuntu.json
├── roles
└── site-cookbooks ((ここより下が追加されている))
└── dnsbalance
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── metadata.rb
├── recipes
│ └── default.rb
└── templates
└── default
├── dns_balance.sbin.erb
├── init.erb
├── ssh-config.erb
└── td-agent.conf.erb

10 directories, 12 files

という具合になる。

vagrantでつくったubuntuにデプロイさせる

run_listに追加、実行

vagrantの中にデプロイするためにrun_listに追加

cdn-dns-v2/nodes$ cat vagrant-ubuntu.json
{"run_list":[
"dnsbalance"
]}

これを加えれば、site-cookbooksの下にあるdnsbalanceの中にある recipes/default.rb を実行させることができる。

あとは
knife solo prepare vagrant-ubuntu

  1. vagrant-ubuntuの中にchefが用意され、

後に
knife solo cook vagrant-ubuntu
を実行すれば、

  1. 親レポジトリの nodes/vagrant-ubuntu.json が読み込まれ、
  2. その結果、recipes/default.rb を実行させることができる。

submodule内容変更時にやること

submoduleで書いたコードに変更があれば

git submodule foreach 'git pull origin master'
を行う

できあがりました!あとはやるだけ!