Contenu connexe
Similaire à [AWSマイスターシリーズ] Amazon Elastic MapReduce (EMR)
Similaire à [AWSマイスターシリーズ] Amazon Elastic MapReduce (EMR) (20)
Plus de Amazon Web Services Japan
Plus de Amazon Web Services Japan (20)
[AWSマイスターシリーズ] Amazon Elastic MapReduce (EMR)
- 1. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
AWS マイスターシリーズ
Amazon Elastic MapReduce
2013.09.25
アマゾンデータサービスジャパン株式会社
ソリューションアーキテクト 大谷 晋平
- 2. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
2
アジェンダ
ビッグデータとクラウド
Amazon Elastic MapReduce(EMR)
EMRとHadoopエコシステム
EMRアーキテクチャ
EMRアドバンスドトピック
まとめ
- 3. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
ビッグデータとクラウドは最高の組み合わせ
ビッグデータ AWSクラウド:
膨大なデータセット 膨大、無制限のキャパシティ
実験的に繰り返し行われる
データの加工と分析
実験的に繰り返しインフラの
構築や使用が可能
波の激しいワークロード 変化するワークロードに効率
的に対応
結果は迅速に 1つのデータソースを並列さ
れたコンピュートクラスタで
処理
設定や管理が困難 マネージドサービス
- 4. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
4
ビッグデータに必要なもの、全てAWSで。
Import Export
Glacier
S3
EC2
RedshiftDynamoDB
EMR S3Direct Connect
- 5. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
5
ビッグデータに必要なもの、全てAWSで。
Import Export
Glacier
S3
EC2
RedshiftDynamoDB
EMR S3Direct Connect
- 6. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
6
- 7. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
7
Apache Hadoopとは?
Big Dataを扱うために:
– スケーラブルな分散ストレージ
– 低価格で柔軟に行うことが出来る分析
Hadoop は上記を満たすオープンソース製品
– HDFS(Hadoop Distributed File System)
– 巨大なデータを扱えるバッチ処理用分散ファイルシステム。
– コモディティサーバに特化。
– MapReduce
– 分散処理である煩わしい点をカバーしてくれる
- 8. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
8
Apache Hadoopとは(2)
エンドユーザが受けるメリット
–誰でも入手可能
–スケーラブル
–柔軟性
– 実績も多く、PBオーダまでリニアにスケール
可能な、分析基盤が誰でも使える
–4000台までスケール
- 9. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
9
Hadoopエコシステム
- 10. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
10
RDBMSとHadoopの違い
RDBMS
• 事前定義したスキーマ
• 1台で稼働する事が前提
• SQLによるアクセス
• リニアにスケールしない
• リアルタイム処理
• 小規模データ
• 構造化データ
Hadoop
スキーマなし
分散・協調して動く前提
SQLでない複数言語サポート
リニアにスケールする
バッチ処理
大規模データ
半構造化データ
- 11. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
11
Hadoopの課題
Hadoopのスケーラビリティを活かすには
大量のサーバが必要
購入してしまうと拡張するのも困難。
自由にノードを追加・縮小できない
データをHDFSだけに保存するのはリスク
• 信頼できるアーカイブ先にデータをシームレ
スにおいておきたい。
- 12. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
Amazon Elastic MapReduce(EMR)
- 13. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
13
Elastic MapReduceとは
3つのシステムの掛け算
- 14. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
14
Elastic MapReduceとは
3つのシステムの掛け算
スケールする
分散バッチ処理
フレームワーク
スケールする
コンピュート
リソース
スケールする
ストレージ
リソース
- 15. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
15
エコシステム
Elastic MapReduceとは
3つのシステムの掛け算+α
スケールする
分散バッチ処理
フレームワーク
スケールする
コンピュート
リソース
スケールする
ストレージ
リソース
- 16. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMRの基本機能
- 17. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
17
EMRの基本動作
1. データを
S3にストア
- 18. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
18
EMRの基本動作
1. データを
S3にストア
2. 選択: Hadoopディストリ
ビューション、ノード数、
ノードタイプ、Hadoopのア
プリ(Hive/Pig/HBase)
- 19. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
19
EMRの基本動作
1. データを
S3にストア
2. 選択: Hadoopディストリ
ビューション、ノード数、
ノードタイプ、Hadoopのア
プリ(Hive/Pig/HBase)
3. クラスタの起動(EMR
コンソール、SDKまたは
APIを使用)
- 20. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
20
EMRの基本動作
1. データを
S3にストア
2. 選択: Hadoopディストリ
ビューション、ノード数、
ノードタイプ、Hadoopのア
プリ(Hive/Pig/HBase)
4. アウトプットを
S3から取得
3. クラスタの起動(EMR
コンソール、SDKまたは
APIを使用)
- 21. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
21
EMRの基本機能
クラスタのリサイ
ズも可能
- 22. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
22
EMRの基本機能
同じデータセット
に対し、処理内容
でクラスタを並列
作成も可能
- 23. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
23
EMRの基本機能
クラスタを終了す
れば課金は停止
- 24. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
24
EMRの基本機能
あるいは永続的に
稼働してHDFS上に
データ保存も可能
- 25. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
25
データの保管場所
HDFS (Hadoop Distributed File System)
• ローカルディスク
• データローカリティの確保による優れたパフォーマンス
• High Storage(hs1)ノードは、ローカルで48TBを持つ
S3
• 99.9999999%の信頼性(11 9’s)
• バージョンコントロール可能
• 柔軟で無制限
• クラスタ間で同一のデータを共有が可能
- 26. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMRとHadoopエコシステム
- 27. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMR上でHiveやPigも簡単に
Pig:
• 高レベルプログラ
ム言語 (Pig Latin)
• UDFに対応
• データフロー/ETL
に最適
Hive:
• Hadoop用のデータウエ
アハウス
• SQLライクなクエリ言
語 (HiveQL)
• 当初Facebookが開発
- 28. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
HBase:
• カラムナ型データベース
• HDFS上で動作
• 疎データに最適
• ランダム リード・ライト
• 巨大なテーブルに最適(数10
億行、数100万列)
Mahout:
• 機械学習のためのライブ
ラリ
• リコメンド、データマイ
ニング、クラスタリング、
および頻度の高い
Itemsetマイニング
EMR上で HBaseやMahoutも簡単に
- 29. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
Ganglia
• 拡張性高い分散モニタリング
ツール
• クラスタおよび個別ノードの
パフォーマンスを表示
• ブートストラップアクション
でインストール
R:
• 統計解析コンピューティン
グとグラフィックスのため
の言語とソフトウエア環境
• 既にインストール済み
GangliaやRもEMRなら、すぐ利用可能
- 30. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
更にSpark や Shark も動く
Shark:
• Hiveで動くHive
• 最大100倍高速
• Hive互換
• Yahoo、AirBnbなど
で使用
Spark:
• インメモリーで
MapReduce
• 最大100倍高速
• HDFS、HBase、S3対応
• UCバークレーにて開発
http://aws.amazon.com/articles/4926593393724923
- 31. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
31
EMRはMapRディストリビューションに
も対応
Amazon Hadoopディストリビューションに加えて、
MapRディストリビューションにも対応
• M3
• M5
• M7(新規追加)
• http://aws.amazon.com/jp/elasticmapreduce/mapr
MapRの主な機能
• NFS/ODBC対応
• No NameNodeなHAアーキテクチャ
• HA Jobtrackerでジョブの喪失を回避
• Mirroringを使ってクラスタ間のデータを同期
• Zero HBase Administration
- 32. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
32
S3DistCp
Apache DistCPの拡張モジュール
• AWS環境に最適化されたDistCp、特にS3
• S3とHDFS間で効率的なデータ転送を行うことが可能
• S3とS3の間でも同様
• 実体はMapReduce
• 転送と同時にサイズ変換・圧縮アルゴリズムの変更
などが可能
• http://docs.amazonwebservices.com/ElasticMap
Reduce/latest/DeveloperGuide/UsingEMR_s3dist
cp.html
- 33. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
33
S3DistCp
CloudFrontのログへの実行例
• S3上のmyawsbucket/cfから
• ローカルのHDFSへ
• GroupByで指定したデータだけ
• 128MBのLZOに圧縮しつつ転送
• 終わったらソースのファイルは削除
./elastic-mapreduce --jobflow j-3GY8JC4179IOK --jar
/home/hadoop/lib/emr-s3distcp-1.0.jar
--args '--src,s3://myawsbucket/cf,
--dest,hdfs:///local,
--groupBy,.*XABCD12345678.([0-9]+-[0-9]+-[0-9]+-[0-9]+).*,
--targetSize,128,
--outputCodec,lzo,--deleteOnSuccess'
- 34. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMRアーキテクチャ
- 35. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMR Hadoop Cluster
Amazon S3
Amazon SimpleDB
BI
Apps
巨大なデータセットや、
膨大なログをアップロードデータ
ソース
Code/
Script
s
Amazon S3
Service
Amazon Elastic
MapReduce
HiveQL
Pig Latin
Cascading
MapReduce
コード
複数のジョブフローの
ステップを実行
JDBC
ODBC
HiveQL
Pig Latin
アドホック
クエリ
EMRの全体アーキテクチャ
Input
Data
Output
Data
メタデータ
Master
Instance
Group
Task
Instance
Group
Master
Node
Task
Node
Task
Node
Core
Instance
Group
HDFS
Core
Node
Core
Node
HDFS
- 36. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
36
EMRのコンポーネント
インスタンスグループ
• Master, Core, Taskの3つ
Master Node
• ジョブ全体を管理。1台のみ起動。
Core Node
• HDFSのDataNodeとTaskTrackerを持つ。
MapReduceも実行。増やせるが減らせない
Task Node
• MapReduceのみを実行。HDFSを持たない
• 足し引き可能
- 37. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
EMRアドバンスドトピック
- 38. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
38
主にBest Practices for EMRから抜粋
トピック
EMRノードとサイズ
タスクノードをいつ使うか
S3上のファイルサイズ
最適化について
- 39. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
39
主にBest Practices for EMRから抜粋
トピック
EMRノードとサイズ
タスクノードをいつ使うか
S3上のファイルサイズ
最適化について
- 40. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
40
ベストプラクティスの適用できる場所は?
EMR/Hadoop全体としては、Input DataからReduceのoutputまでの
利用空間効率を高めることが重要
Input Data Map Slot Reduce SlotShuffle &
Sort
- 41. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
41
サイジングにおけるベストプラクティス
どうクラスタを
サイジングする
べきか
Input Data Map Slot Reduce SlotShuffle &
Sort
- 42. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
42
EMRのノードとサイズ
• アプリケーションとして最も負荷がかかる部分は
どこかの把握が大切
• HadoopのMap/Reduceスロット数、Heapサイズなどの設定はイ
ンスタンスごとにデフォルト値が決められている
• http://docs.aws.amazon.com/ja_jp/ElasticMapReduce/late
st/DeveloperGuide/HadoopMemoryDefault_AMI2.2.html
• スタート地点としてはm1.xlarge
• メモリインテンシブなジョブにはm2/cc2
• CPUインテンシブなジョブにはcc2/c1x.large
• HDFSインテンシブな場合はHs1を使う
• M1.small/m1.largeはテスト用が現実的
- 43. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
43
EMRのノードとサイズ
• いくつノードが必要かは(ほとんどの場合)
データの入力サイズによる
• より大きいデータ入力サイズ=多くのMapper=
多くのノード
• ジョブの完了までの期待値にもよる
• インスタンスサイズによって、一定量の
Mapper/Reducerサイズを持つ
• 多くのノード = 多くのMapper = Mapステー
ジがより早く完了する
- 44. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
44
主にBest Practices for EMRから抜粋
トピック
EMRノードとサイズ
タスクノードをいつ使うか
S3上のファイルサイズ
最適化について
- 45. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
45
タスクノードをいつ使うか
• Mapperが大量に必要な時
• S3から大量データをロードするとき
• Select x,y,z from some_table = mapper jobだが、大
量の処理パワーが必要ないとき
• タスクノードの大量なMapperを一時的にスポットで
使って、HDFSへデータをロードしてシャットダウン
• 短時間でのジョブで大量に処理パワーが必要
な場合
- 46. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
46
主にBest Practices for EMRから抜粋
トピック
EMRノードとサイズ
タスクノードをいつ使うか
S3上のファイルサイズ
最適化について
- 47. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
47
S3上のファイルサイズ
• 小さいファイルは避ける
• 理由:Mapperのオーバヘッド
• JVMの初期化コスト: CPU/Mem
• 各Mapperは起動するのに約2秒
• 100MBのデータが10TB分なら、100,000
mapper x 2秒 = Mapperのセットアップだけで
55時間
• これが1000MBのデータが10TB分なら、10,000
mapper x 2秒 = Mapperのセットアップは5時間
- 48. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
48
S3上のファイルサイズ
• Hadoop用に最適なS3のファイルサイズは?
• 小さすぎると性能が出ない
• 勿論HDFSのブロックサイズよりは大きい方
が良い(EMRのデフォルトは128MB)
• Hadoop用に最適なS3のファイルサイズは?
• スプリットできないもので1-2GBくらい
- 49. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
49
S3上のファイルサイズ
• スプリットできるもの: LZO形式など
• 2-5GB程度がベスト
• 何故それくらいなのか?
• Mapper数が多すぎると、S3サイドでAPIスロッ
トリングや単一キーアクセスが頻発する可能性
• S3は同一キーに対して大量のレンジGETしすぎる
と、スロットリング対象になる可能性が高い
- 50. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
groupByで複数のファイルを結合しつつ、圧縮コーデック
をgzipからlzoに変換してS3から(HDFS|S3)に転送。その
際に1ファイルを1GB前後ずつに切り分ける。
50
$ elastic-mapreduce
--create
--jar s3://EMRBUCKET/libs/s3distcp/1.latest/s3distcp.jar
--args
'--src,s3://INPUTBUCKET/nginx/,
--groupBy,.*([0-9]{8}-[0-9]{2}).*.gz,
--outputCodec,lzo,
--targetSize,1024,
--dest,hdfs:///OUTPUTBUCKET/'
S3DistCpによるS3上のデータのサイズ変更
- 51. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
hiveに最適なデータ配置にしておきたい場合は、hiveの
insert文を使ってデータをS3上の外部テーブルにINSERT
してやることでも実現可能。
51
hive> INSERT OVERWRITE INTO ${output_external_table}
SELECT * FROM ${input_external_table}
HiveのInsertによるデータの再配置
- 52. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
52
S3 DistCpを使った再配置
web server
web server
web server
HDFSにロード
FluentdS3Plugin
整理してS3に再配置
S3DistCp/Hive
この時点だと
ファイルはまだ
小さいファイル
適切なファイル
サイズに集約&
再分割
- 53. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
53
圧縮
• 圧縮はなるべくしましょう
• S3
• Mapperのアウトプット
• ディスク書き込みの削減
• シャッフルサイズの削減(NWに易しい)
• http://docs.aws.amazon.com/ElasticMapReduce/latest/Deve
loperGuide/IntermediateCompression_AMI2.3.html
• Reducerのアウトプット
• ディスク書き込みの削減
• Mapperのスピル
• ディスク書き込みの削減
splits 0 Map
Map
Map
Reduce
Reduce
Part 0
Part 1
Copy
Sort
Merge
Merge
Inputs
splits 1
splits 2
Compression
- 54. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
54
圧縮
• 適切な圧縮形式を選びましょう
• 速いが、圧縮効率が良くない
• 圧縮効率は良いが遅い
• スプリット可能か、そうではないか
- 55. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
55
主にBest Practices for EMRから抜粋
トピック
EMRノードとサイズ
タスクノードをいつ使うか
S3上のファイルサイズ
最適化について
- 56. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
56
アドバンスドな最適化
• 最も良い最適化はデータの構造化 (例えば賢い
データパーティショニング等)
• 効率的なデータ構造=Hadoopで処理するデー
タ量の抑制=高速なジョブ
- 57. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
57
アドバンスドな最適化
• Hadoopはバッチフレームワーク
• データ処理の単位 = 時間から日にち単位
• 短時間すぎるジョブには向いていない
• 他のフレームワークのほうが向いている
• Twitter Storm
• Spark
• Redshift
- 58. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
58
アドバンスドな最適化
• EMRはEMRチームが既にかなり最適化している
• まずはデフォルト値を抑えよう
• http://docs.aws.amazon.com/ElasticMapReduce/latest/Dev
eloperGuide/Default_Config_AMI2.3.html
• クラスタサイズが小さいと、EMRの設定の最適
化はあまり効果がない
• AWSベストプラクティス:制約を恐れない
• インスタンスのコストは1時間単位なのでそれを念頭
に置くこと
- 59. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
59
アドバンスドな最適化
インスタンスを普通に
追加するのがほとんど
の場合で正解
- 60. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
60
アドバンスドな最適化(続)
• Gangliaでモニタリング
• どこがボトルネックかをまずは発見する
• Memory
• CPU
• ディスクIO
• ネットワークIO
- 61. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
61
CPU
• クラスタのCPU利用率は常に監視する
• CPUをフルに使い切っていない場合、ノード単
体あたりのタスク数をあげる事を検討
• クラスタのノード数を減らす
- 62. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
62
Memory
• Gangliaのメモリ項目を監視
• メモリを使い切っている場合は:
• Mapperタスクあたりのメモリ量を上げる
- 63. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
63
ディスクIO
• ディスクIOを監視
• ディスクIOは大きなボトルネックになる可能性アリ。
• Mapperスピル
• Reducerスピル
• SPILLED_RECORDSメトリクスを監視して、メモリを増やす
なりしてスピルする量を減らす(後述)
• 象本第2版 P195
- 64. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
64
ディスクIO
• Mapperのスピルするデータ:
• MAPPER_SPILLED_RECORDS >
MAPPER_OUTPUT_RECORDS = ディスクにスピ
ルする量
• io.sort.mb パラメータを増やして、Mapperのメモ
リ量を増やす
• Combinerを使う
• Reducerでも同じ
- 65. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
65
Network IO
• S3とEMRを併用するなら、 Gangliaでネット
ワークスループットは見ておくこと
• 各ノードのMapperのNICスループットを最大
化する
• 例えば:
• 大きめのインスタンスで言えば800Mbps-2Gbpsは
出る
• Gangliaでクラスタ全体のスループット < ノード数
x 800Mbps|2Gbps なら、Mapper数を増やす
- 66. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
66
まとめ
EMRはビッグデータ処理のためのHadoopサービス
• EMR=EC2 x S3 x Hadoopエコシステム
Hadoopの運用管理自体は何も価値を生みません。より
データ分析に時間を!
EMRではクラスタのサイズや大きさを柔軟に変更可能
ベストプラクティスも蓄積されつつあり、いよいよ本格
普及期に入った
- 67. © 2012 Amazon.com, Inc. and its affiliates. Allrights reserved. May not be copied, modified or distributed in w hole or in part w ithout the express consent of Amazon.com, Inc.
67
追加のリソース
Amazon Elastic MapReduce(EMR)の概要
• http://aws.amazon.com/jp/elasticmapreduce/
EMRベストプラクティス
• http://media.amazonwebservices.com/AWS_Amazon_EM
R_Best_Practices.pdf
Amazon EMR よくある質問
• http://aws.amazon.com/jp/elasticmapreduce/faqs/
Amazon EMR 料金表
• http://aws.amazon.com/jp/elasticmapreduce/pricing/