[続報]MongoDBをext3とext4でベンチマークしてみた(mongod 2.0編)
たくさんのブクマ・リツイートありがとうございます!
(疑問の声が多かったのには正直びっくりしました・・)
ご要望にお応えして、MongoDB 2.0.4で再チャレンジ!
そしてAmazon EC2でもやってみた!
実験方法
あらかじめext3のディスクとext4のディスクを作成してサーバにマウントしておきます。テストコード
掛け算の九九表をあらわすオブジェクトを、無限ループでひたすらinsertする仕組みです。kuku.js
var kuku = {} ;
for( var i = 1; i<=9 ;i++) {
kuku[i] = {};
for (var j = 1; j <=9 ; j++) {
kuku[i][j] = i * j ;
}
}
while(true) { db.test.save({ kuku :kuku, time:new Date()}); }
まずmongodサーバを起動して、データ保存先をext3に指定します。
$ cd mongodb-linux-x86_64-2.0.4
$ bin/mongod --dbpath /mnt/ext3/db > logfile_ext3 &
つぎにmongoクライアントを4つ立ち上げて、九九オブジェクトを無限ループでインサートし続けます。
$ bin/mongo --quiet kuku.js &
$ bin/mongo --quiet kuku.js &
$ bin/mongo --quiet kuku.js &
$ bin/mongo --quiet kuku.js &
2GBのデータファイルが3個できた時点で終了します。ext3の実験が終わったら、全く同じ手順でext4の実験をします。
ニフティクラウドでの実験結果
- サーバ:ニフティクラウド サーバmini [1vCPU(1GHz)・512MB]
- ディスク:Disk200 B
- OS:CentOS release 6.2 (64bit)
- mongodb-linux-x86_64-2.0.4
ext3
ファイルアロケーションにかかった時間# grep "done allocating" logfile_ext3
Fri Apr 27 02:42:30 [FileAllocator] done allocating datafile /mnt/ext3/db/test.ns, size: 16MB, took 0.228 secs
Fri Apr 27 02:42:30 [FileAllocator] done allocating datafile /mnt/ext3/db/test.0, size: 64MB, took 0.853 secs
Fri Apr 27 02:42:33 [FileAllocator] done allocating datafile /mnt/ext3/db/test.1, size: 128MB, took 2.243 secs
Fri Apr 27 02:43:20 [FileAllocator] done allocating datafile /mnt/ext3/db/test.2, size: 256MB, took 7.693 secs
Fri Apr 27 02:46:15 [FileAllocator] done allocating datafile /mnt/ext3/db/test.3, size: 512MB, took 16.313 secs
Fri Apr 27 02:49:29 [FileAllocator] done allocating datafile /mnt/ext3/db/test.4, size: 1024MB, took 34.438 secs
Fri Apr 27 02:56:13 [FileAllocator] done allocating datafile /mnt/ext3/db/test.5, size: 2047MB, took 66.262 secs
Fri Apr 27 03:09:16 [FileAllocator] done allocating datafile /mnt/ext3/db/test.6, size: 2047MB, took 48.832 secs
Fri Apr 27 03:39:06 [FileAllocator] done allocating datafile /mnt/ext3/db/test.7, size: 2047MB, took 49.767 secs
Disk200の性能を持ってしても、2GBファイルのアロケーションに60秒越え・・・やっぱり遅い気がしますよ!
(注:Disk200というのは100GBあたり1万円/月の高級品デス)
ext4
# grep &;quot;done allocating&;quot; logfile_ext4
Fri Apr 27 03:46:29 [FileAllocator] done allocating datafile /mnt/ext4/db/test.ns, size: 16MB, took 0.001 secs
Fri Apr 27 03:46:29 [FileAllocator] done allocating datafile /mnt/ext4/db/test.0, size: 64MB, took 0.013 secs
Fri Apr 27 03:46:29 [FileAllocator] done allocating datafile /mnt/ext4/db/test.1, size: 128MB, took 0.002 secs
Fri Apr 27 03:47:11 [FileAllocator] done allocating datafile /mnt/ext4/db/test.2, size: 256MB, took 0.017 secs
Fri Apr 27 03:49:51 [FileAllocator] done allocating datafile /mnt/ext4/db/test.3, size: 512MB, took 0.04 secs
Fri Apr 27 03:54:13 [FileAllocator] done allocating datafile /mnt/ext4/db/test.4, size: 1024MB, took 0.032 secs
Fri Apr 27 04:00:30 [FileAllocator] done allocating datafile /mnt/ext4/db/test.5, size: 2047MB, took 0.097 secs
Fri Apr 27 04:13:22 [FileAllocator] done allocating datafile /mnt/ext4/db/test.6, size: 2047MB, took 0.054 secs
Fri Apr 27 04:39:51 [FileAllocator] done allocating datafile /mnt/ext4/db/test.7, size: 2047MB, took 0.163 secs
なにこれすごい
Amazon EC2/EBS
ニフティクラドの結果がピンとこない方のために、みんな大好きAmazon EC2/EBSでもやってみましたよ。- Amazon EC2 ap-northeast-1b
- CentOS 6.2 x86_64 m1.large
- mongodb-linux-x86_64-2.0.4
ext3
# grep "done allocating" logfile_ext3
Thu Apr 26 14:54:25 [FileAllocator] done allocating datafile /mnt/ext3/db/test.ns, size: 16MB, took 0.372 secs
Thu Apr 26 14:54:26 [FileAllocator] done allocating datafile /mnt/ext3/db/test.0, size: 64MB, took 1.394 secs
Thu Apr 26 14:54:29 [FileAllocator] done allocating datafile /mnt/ext3/db/test.1, size: 128MB, took 3.138 secs
Thu Apr 26 14:54:44 [FileAllocator] done allocating datafile /mnt/ext3/db/test.2, size: 256MB, took 6.066 secs
Thu Apr 26 14:55:14 [FileAllocator] done allocating datafile /mnt/ext3/db/test.3, size: 512MB, took 12.18 secs
Thu Apr 26 14:56:09 [FileAllocator] done allocating datafile /mnt/ext3/db/test.4, size: 1024MB, took 22.587 secs
Thu Apr 26 14:58:04 [FileAllocator] done allocating datafile /mnt/ext3/db/test.5, size: 2047MB, took 45.789 secs
Thu Apr 26 15:01:13 [FileAllocator] done allocating datafile /mnt/ext3/db/test.6, size: 2047MB, took 51.251 secs
Thu Apr 26 15:06:56 [FileAllocator] done allocating datafile /mnt/ext3/db/test.7, size: 2047MB, took 57.013 secs
やはり遅い
ext4
# grep "done allocating" logfile_ext4
Thu Apr 26 15:24:41 [FileAllocator] done allocating datafile /mnt/ext4/db/test.ns, size: 16MB, took 0.005 secs
Thu Apr 26 15:24:41 [FileAllocator] done allocating datafile /mnt/ext4/db/test.0, size: 64MB, took 0.002 secs
Thu Apr 26 15:24:41 [FileAllocator] done allocating datafile /mnt/ext4/db/test.1, size: 128MB, took 0.005 secs
Thu Apr 26 15:24:51 [FileAllocator] done allocating datafile /mnt/ext4/db/test.2, size: 256MB, took 0.003 secs
Thu Apr 26 15:25:10 [FileAllocator] done allocating datafile /mnt/ext4/db/test.3, size: 512MB, took 0.01 secs
Thu Apr 26 15:25:46 [FileAllocator] done allocating datafile /mnt/ext4/db/test.4, size: 1024MB, took 0.007 secs
Thu Apr 26 15:26:58 [FileAllocator] done allocating datafile /mnt/ext4/db/test.5, size: 2047MB, took 0.009 secs
Thu Apr 26 15:29:29 [FileAllocator] done allocating datafile /mnt/ext4/db/test.6, size: 2047MB, took 0.021 secs
Thu Apr 26 15:34:37 [FileAllocator] done allocating datafile /mnt/ext4/db/test.7, size: 2047MB, took 0.024 secs
すげーーーーーSUGEEEEEEーー!!!!!!!
まとめ
ext4のファイルアロケーションはめちゃ速い
ロードアベレージも測定していましたが、常時5~7でext3とext4の差はありませんでした。 (insertするプロセスの数が4で固定だったからか?)
また誤解されがちなのですが、本実験はファイルアロケーションの性能を測るものであって、insert性能を測るものではありません。
insert性能については、下記トータル所要時間(16MB作成~2047MB作成までに要した時間)を見ていただくとわかるように、10%~20%程度の性能差と思われます。
なんでファイルアロケーションの速度にこだわるのかというと、アロケートのタイミングでプチフリ(突発的な負荷上昇)が起きてしまうからです。
(参考)トータル所要時間
ext3 | ext4 | |
Nifty | 57分 | 53分 |
Amazon | 12分 | 10分 |
NiftyとAmazonはスペックが全然違うので、比較しないでくださいね。
NiftyよりAmazonの方が速いとかそういう意味ではありません。あしからず。
カテゴリ:
MongoDB