スティルハウスの書庫の書庫

はてなダイアリーで書いてた「スティルハウスの書庫」を移転してきました。

#appengine MapReduceで毎秒2000件×8日間=15億件を処理!

まだMapper APIのみの提供でReducer APIがないappengine-mapreduceライブラリについては、10万件のデータを対象としたテストでは1000件/秒程度で処理できたよというレビューをお届けしました。しかしApp Engineの中の人であるBrettさんは15億件のデータを対象としてmapper APIを試したところ、毎秒2000件以上のスループットを達成したそうです。以下におもな点を要約します:

Brett Slatkin - One Big Fluke - Biggest Map() of my own.

I recently ran the biggest Map() job of my life on my own data using the new App Engine Mapper framework: 1.5 Billion rows. The data was from the PubSubHubbub reference hub I built and run for Google (it uses App Engine, my day job). The Map job's goal was to update all Datastore entities of a certain type to use less space (700GB less, ~60% reduction, fun graphs below). These entities are used to track changes to feeds over time, which means I have to store one "row" for each feed item for a long time (perhaps my own version of Yucca mountain).
  • BrettさんがApp Engine上で運用してたPubSubHubbub(PSHB)ハブで生成された15億件のエンティティに対して、appengine-mapreduceのmapperジョブを実行した
  • PSHBで扱う個々のフィードアイテムにつき1件エンティティを長期間保持し、フィードの変更を監視している。そのすべてのエンティティをmapper APで処理し、60%以上・700GBのデータ削減を行った
I ran my job on 16 shards, meaning 16 CPU cores were in use at a time in parallel. My results surprised me! Here are the important stats:

    * Elapsed time: 8 days, 12:59:25
    * mapper_calls: 1533270409 (2077.7/sec avg.)

That's right, 2000+ entity writes per second sustained for 8+ days straight. That's 125 writes/sec/shard. 
  • 16のシャードで並列処理された(訳注:私のテスト時は最大8シャードまで。1シャード1CPUコアなんだね。。1VM1CPUコアってことか?)
  • 15億件を8日と13時間で処理完了、平均2077.7件/秒のスループットが得られた!
Yes, this was on App Engine. Did you know it could do that? And I saw it peek at 3000+. Wow! What impresses me further is part of the job ran during this Datastore maintenance period, when all Datastore writes were temporarily disabled. The Mapper framework handled the outage without a problem and continued without my intervention once Datastore writes were re-enabled. Running a job like this through datacenter maintenance is unheard of in my experience.
  • App Engineでこんなこと出来るって知ってた!?ピーク時は3000件/秒以上処理してたんだよ〜スゴス!
  • しかもこのジョブ、途中でDatastoreのメンテナンスを挟んだので、書き込み処理が一時的に使えなくなってた。でもMapperフレームワークは問題なく対処して、ほっておいてもメンテナンス終了時に自動的に処理を継続してた。
  • データセンターのメンテナンス中にこんなバッチジョブ走らせておくなんて聞いたことないよ
In terms of cost, the map job only doubled the daily price of running Google's Hub on App Engine. That's awesome, especially considering the amount of low-hanging-optimization fruit (mmm... delicious) still present in the Mapper framework. I expect us to deliver an order of magnitude of efficiency and performance improvements for the framework.
  • コストについては、普段のPSHBの課金が倍に増えただけだった。
  • すごいのは、appengine-mapreduceにはまだまだ最適化できる部分がたっぷりあること(おいしそう〜)。今後けた違いに速くなる可能性もあるよ。

...ということで、2000件/秒ていうのはまだまだ序の口らしいです。15億件が対象なのに16CPUってのもスケールアウト不足な感じなので、もう1ケタくらいスケールアウトしてもいい気がします(CPUバウンドじゃなくてDatastoreバウンドかな?)

それとこの前、Brettに「肝心のreducer APIやshuffleの実装は難しいのでは?」と振ったら「たしかに難しいねぇ。。」と渋い顔してたので、reduceサポートはもうちょっと先になりそうです。。がんばれ!打倒Hadoopだ!