Google Cloud Dataflow
を理解する
Slava Chernyak, Senior Software Engineer
chernyak@google.com
Googleのビッグデータ
Cloud Dataflow SDK
Cloud Dataflow Service
バッチ処理とストリーム処理
全体の連携
1
2
3
4
5
アジェンダ
Googleのビッグデータ
Googleでは
ビッグデータを表す
特別な用語を使います
What is Big Data at Google?
「データ」
What is Big Data at Google?
2012 20132002 2004 2006 2008 2010
Cloud Dataflow
Googleのビッグデータ処理の歴史
Why Cloud Dataflow?
MapReduce
GFS Big Table
Dremel
Pregel
Flume
Colossus
Spanner
MillWheel
保存する集める 分析する
BigQuery Larger
Hadoop
Ecosystem
Hadoop
Spark (on
GCE)
Pub/Sub
Logs
App Engine
BigQuery streaming
処理する
Dataflow
(stream and
batch)
Cloud
Storage
(objects)
Cloud
Datastore
(NoSQL)
Cloud SQL
(mySQL)
BigQuery
Storage
(structured)
Hadoop
Spark (on
GCE)
Google Cloud Platformによるビッグデータ処理
Cloud Dataflowとは何か
Cloud Dataflowは
並列化された
データ処理パイプラインを作
るためのSDK群
What is Cloud Dataflow?
Cloud Dataflowは
並列化された
データ処理パイプラインを
実行するための
マネージドサービス
What is Cloud Dataflow?
• 移動
• フィルタ
• 加工
• 整形
• 集約
• バッチ処理
• ストリーム処理
• 組み合わせ
• 外部連携
• シミュレーション
Cloud Dataflowは何に使えるか?
• (変換に基づく)関数型プログラミングモデル
• バッチ処理とストリーム処理を統合
• クラスタ管理の運用コストを削減
• 次世代のプラットフォームによるジョブ実行時間の縮小
• SDK、プラグイン、Runner等のオープンソース エコシステム
Cloud Dataflowのメリット
What is Cloud Dataflow?
Cloud Dataflowのリリース スケジュール
What is Cloud Dataflow?
• June 24, 2014: Google I/Oで発表
• Dec. 17, 2014: Alpha版
• Apr. 15, 2015: Beta版
• 次は: 一般公開
Cloud Dataflow SDK
ハッシュタグのオートコンプリートの実装例
入力した文字列 サジェストするリスト
#ar #argentina, #arugularocks, #argylesocks
#arg #argentina, #argylesocks, #argonauts
#arge #argentina, #argentum, #argentine
{a->[apple, art, argentina], ar->[art, argentina, armenia],...}
Count
ExpandPrefixes
Top(3)
Write
Read
ExtractTags
{a->(argentina, 5M), a->(armenia, 2M), …, ar->
(argentina, 5M), ar->(armenia, 2M), ...}
{#argentina scores!, watching #armenia vs
#argentina, my #art project, …}
{argentina, armenia, argentina, art, ...}
{argentina->5M, armenia->2M, art->90M, ...}
Tweets
Predictions
Count
ExpandPrefixes
Top(3)
Write
Read
ExtractTags
Tweets
Predictions
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
p.run();
.apply(ParDo.of(new ExtractTags()))
.apply(Top.largestPerKey(3))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(TextIO.Write.to(“gs://…”));
.apply(TextIO.Read.from(“gs://…”))
class ExpandPrefixes … {
public void processElement(ProcessContext c) {
String word = c.element().getKey();
for (int i = 1; i <= word.length(); i++) {
String prefix = word.substring(0, i);
c.output(KV.of(prefix, c.element()));
}
}
}
• 異なるRunnerを使い、同じコードをさまざまな方法で実行可能
• Direct Runner
• ローカル環境でインメモリ実行できる
• 開発やテストに最適
• Cloud Dataflow Service Runner
• フルマネージドのDataflowサービス上で動作
• 複数のGCEインスタンス上で分散実行
• コミュニティによる実装
• Spark runner @ github.com/cloudera/spark-dataflow
• Flink runner coming soon from dataArtisans
Cloud Dataflow Runners
Cloud Dataflow Service
Google Cloud Dataflow
最適化
スケジューリング
GCS GCS
ユーザコードとSDK モニタリングUI
パイプラインの流れ
800 RPS 1,200 RPS 5,000 RPS 50 RPS
ワーカーのスケーリング
100 mins. 65 mins.
洗練されたタスク スケジューリング
vs.
バッチ処理とストリーム処理
Google Cloud Pub/Subでストリームを読み書き
ストリーム処理しよう!
• リージョン間冗長化
• 低レイテンシ(ms単位)
• N:Mメッセージング
• リードとライトのバッチ化
• カスタム ラベル
• プッシュ & プル
• 自動停止
Cloud Pub/Sub
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(TextIO.Read.from(“gs://…”))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(TextIO.Write.to(“gs://…”));
p.run();
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(TextIO.Read.from(“gs://…”))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(TextIO.Write.to(“gs://…”));
p.run();
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(PubsubIO.Read.topic(“input_topic”))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(PubsubIO.Write.topic(“output_topic”));
p.run();
時間
#ar*の
ランク
試合開始 アルメニアが
勝った!
#argyle
#armeniarocks
時間によるデータの変化
#argentinagoal
ストリーム処理しよう!
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(PubsubIO.Read.topic(“input_topic”))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(PubsubIO.Write.topic(“output_topic”));
p.run();
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(PubsubIO.Read.topic(“input_topic”))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(PubsubIO.Write.topic(“output_topic”));
p.run();
Pipeline p = Pipeline.create(new PipelineOptions());
p.begin()
.apply(PubsubIO.Read.topic(“input_topic”))
.apply(Window.into(SlidingWindows.of(
Duration.standardMinutes(60)))
.apply(ParDo.of(new ExtractTags()))
.apply(Count.perElement())
.apply(ParDo.of(new ExpandPrefixes())
.apply(Top.largestPerKey(3))
.apply(PubsubIO.Write.topic(“output_topic”));
p.run();
Google Cloud Dataflow
ストリーム処理の最適化
ストリーム処理の
スケジューリング
Pub/Sub Pub/Sub
パイプラインの流れ
VMの中身は?
Javaハーネスプロセス
ユーザーのJavaコード
ストリーミングDataflowサービス プロセス
11:59 12:00 12:01 13:00
60分のスライディングウィンドウ
シャッフル入力 シャッフル出力
全体の連携
❯ Google Cloud Platformの各種データソー
スから入力
• GCS, Pub/Sub, BigQuery, Datastore
❯ カスタム記述により任意のデータソースから
の並列入力
• 現在はバッチ処理のみ対応
❯ GCS, BigQuery, Pub/Subへの出力
• 今後も追加予定
❯ テキスト、JSON、XML、Avro等のフォーマッ
トを利用可能
Your
Source/Sink
Here
入力と出力
● Dataflow SDKのPythonサポート
● さらに強力な機能をDataflow SDKに追加
● Dataflowサービスを今後も改善
● さらにいろいろ!
今後の展望
エンジニアの作業時間を節約
(provisioning)
エンジニアの作業時間を節約
(fault-tolerance)
エンジニアの作業時間を節約
(deployment issues)
エンジニアの作業時間を節約
(improving utilization)
エンジニアの作業時間を節約
(performance tuning)
エンジニアの作業時間を節約
エンジニアの作業時間を節約
エンジニアの作業時間を節約
Thank You!
cloud.google.com/dataflow
cloud.google.com/dataflow
stackoverflow.com/questions/tagged/google-cloud-dataflow
github.com/GoogleCloudPlatform/DataflowJavaSDK
はじめよう

Google Cloud Dataflow を理解する - #bq_sushi