awsではじめるデータレイク」出版記念 glue, lake formation, athena… · 3...
TRANSCRIPT
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
1
Amazon Web Services Japan, K. K.
2020/06/18
「AWSではじめるデータレイク」出版記念
Glue, Lake Formation, Athena, EMR
最新アップデート
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2
自己紹介
川村 誠
Hadoop/Spark スペシャリスト
ソリューションアーキテクト
• データ分析系サービスを担当
• 好きなサービス
• Amazon EMR
• Amazon Athena
• AWS Glue
• Amazon SageMaker
3
AWSオンラインセミナーへようこそ
ご質問を受け付けております!
• 書き込んだ質問は主催者にしか見えません
• 最後のQ&A時間で、いただいたご質問からピックアップしてご回答をさせていただきます
① 吹き出しをクリック② 質問を入力③ Sendをクリック
終了後にアンケートの記入をお願いいたします
https://amazonmr.au1.qualtrics.com/jfe/form/SV_418MiPMsc8fx5c1短いバージョン
https://bit.ly/3hAyXIF
アンケートにお答えいただいた方には本日の資料を後日ご提供させていただきます。
4
データレイクの書籍が発売になります!
2020年7月発売予定
http://techiemedia.co.jp/
データレイクの基本概念から
関連AWSサービスの説明、
構築方法まで
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
5
振り返り
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
6
データレイクとは
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
7
データレイクとは
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
8
データレイク構築の基本的な考え方
• データ蓄積とデータ処理を分離する
• 処理においては,複数ジョブの並列処理や,単一ジョブも複数マシンにまたがった分散処理をベースに考える
• コンポーネント間の連携を疎にする
• やりたいことに合わせて,適切なツールを選択する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
9
ベーシックなデータレイクのアーキテクチャ
収集 変換 分析
保存(ストレージ + データカタログ)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
10
データレイクのコンポーネントに対応する AWS サービス
Amazon Database
Migration Service
Amazon Kinesis
Amazon S3
AWS Glue
AWS Lake Formation
AWS Glue
AWS Lake Formation
Amazon QuickSight
Amazon Athena
Amazon Redshift Amazon SageMaker
Amazon Personalize
Amazon Forecast
Amazon Elasticsearch Service
Amazon Managed
Streaming for Kafka
収集 保存 変換 分析
Amazon
AppFlow Amazon EMR
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
11
データレイクのコンポーネントに対応する AWS サービス
Amazon Database
Migration Service
Amazon Kinesis
Amazon S3
AWS Glue
AWS Lake Formation
AWS Glue
AWS Lake Formation
Amazon QuickSight
Amazon Athena
Amazon Redshift Amazon SageMaker
Amazon Personalize
Amazon Forecast
Amazon Elasticsearch Service
Amazon Managed
Streaming for Kafka
収集 保存 変換 分析
Amazon
AppFlow Amazon EMR
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
12
Agenda
• AWS Glue updates
• Amazon Athena updates
• Amazon EMR updates
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
13
AWS Glue updates
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
14
AWS Glue
様々なデータソースのメタデータを収集・活用した、フルマネージドでサーバーレスな分散処理サービス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
15
AWS Glue の特徴
AWS Glue
サーバーレス 柔軟な起動方法
コードに集中データソースのメタデータ管理
VPC内からのアクセス他のAWSサービスと容易に連携
Notebookでの開発セキュア
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
16
AWS Glue updates
• Streaming ETL ジョブ
• Glue Spark ETL ライブラリアップデート
• Amazon DocumentDB / MongoDB への読み書きに対応
• Glue Data Catalog への書き込みに対応
• S3 データ用の新しい変換 (消去、移行、結合) を追加
• Glue Spark ETL ジョブ、カスタム JDBC ドライバーに対応
• Preview: Reduced start times for Spark jobs
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
17
Streaming ETL ジョブ
• Glue Spark ジョブの新しいタイプ
• ストリームに流れてくる鮮度の高いデータを活用
• Apache Spark の Structured Streaming を利用しストリーミングデータのクリーニングと変換処理をマイクロバッチ処理として継続的に実行
• 入力:
• Amazon Kinesis Data Streams
• Amazon MSK
• Apache Kafka
• 出力:
• Amazon S3
• JDBC
※「Apache Spark, Apache Kafkaは、Apache Software Foundationの登録商標または商標です。」
Amazon Managed
Streaming for KafkaAmazon Managed
Streaming for KafkaApache Kafka ※
AWS Glue
Streaming ETL job
JDBC DataStoreAmazon S3
https://aws.amazon.com/jp/about-aws/whats-new/2020/04/aws-glue-now-supports-serverless-streaming-etl/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
18
Streaming ETL ジョブ
• Streaming ジョブの利用方法
• ストリーミングデータソースに対するテーブル定義/接続定義を作成
• Glue Streaming ETL ジョブ (Type=Spark Streaming) を作成
https://aws.amazon.com/blogs/aws/new-serverless-streaming-etl-with-aws-glue/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
19
Streaming ETL ジョブargs = getResolvedOptions(sys.argv, ['JOB_NAME'])
sc = SparkContext()glueContext = GlueContext(sc)spark = glueContext.spark_sessionjob = Job(glueContext)job.init(args['JOB_NAME'], args)
datasource0 = glueContext.create_data_frame.from_catalog(database = "streaming-test"
def processBatch(data_frame, batchId):if (data_frame.count() > 0):
dynamic_frame = DynamicFrame.fromDF(glueContext.add_ingestion_time_columns(data_frame, dynamic_frame.printSchema()dynamic_frame.toDF().show()
apply_mapping = ApplyMapping.apply(frame = dynamic_frame, mappings = [("ventilatorid"("minutevolume", "long", "minutevolume", "long"), ("manufacturer", "string", "manufacturer"
apply_mapping.printSchema()apply_mapping.toDF().show()
additionalOptions = {"enableUpdateCatalog": True}additionalOptions["partitionKeys"] = ["ingest_year", "ingest_month", "ingest_day"datasink1 = glueContext.write_dynamic_frame.from_catalog(frame = apply_mapping,
glueContext.forEachBatch(frame = datasource0, batch_function = processBatch, options = {
"windowSize": "100 seconds", "checkpointLocation": "s3://bucket/path_to_checkpoint/"
})job.commit()
ストリーミングに関する設定
マイクロバッチ内で実行される関数
100秒ごとの実行
DataFrame -> DynamicFrame
DynamicFrame -> S3
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
20
AWS Glue を使用したストリーミングデータ処理例
https://aws.amazon.com/jp/blogs/news/new-serverless-streaming-etl-with-aws-glue/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
21
振り返り
ストリーム処理に関するトピックスは第2回セミナーをご参照ください
Amazon Managed
Streaming for KafkaAmazon Managed
Streaming for KafkaApache Kafka ※ AWS Glue
Streaming ETL job
※「Apache Spark, Apache Kafkaは、Apache Software Foundationの登録商標または商標です。」
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
22
Glue Spark ETL ライブラリアップデート:
Amazon DocumentDB / MongoDB への読み書きに対応
Amazon DocumentDB (MongoDB 互換) 、および、MongoDB コレクションからAmazon S3 や Amazon Redshift などのサービスに対する、ダウンロードストリーム分析のためのデータの読み出し、変換、およびローディングに、Glue
Spark ETL ジョブが使用可能に。
https://aws.amazon.com/jp/about-aws/whats-new/2020/04/aws-glue-now-supports-reading-from-
amazon-documentdb-and-mongodb-tables/
Amazon DocumentDB
(with MongoDB
compatibility)
MongoDBは、MongoDB Inc.の商標または登録商標です。
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
23
Glue Spark ETL ライブラリアップデート:
Glue Data Catalog への書き込みに対応
• 従来: 既存テーブル内での新たなテーブル作成やスキーマの変更、パーティション追加を実施する場合に ETL ジョブ後の Glue クローラの実行が必要
• 本アップデートでGlue Data Catalog で新しいテーブルを作成し、スキーマとパーティションを更新する機能をサポート
• Glue クローラの実行が不要となり、Glue クローラの実行にかかっていた時間とコストが削減可能に
https://aws.amazon.com/jp/about-aws/whats-new/2020/04/aws-glue-now-supports-the-
ability-to-update-partitions-from-glue-spark-etl-jobs/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
24
Glue Spark ETL ライブラリアップデート: S3 データ用の新しい変換 (消去、移行、結合) を追加
Glue Spark ジョブで ETL ロジックを拡張するのに役立つ 3 つの新しい変換 (消去、移行、結合) を追加
• 消去 (purge): ファイル、パーティション、またはテーブルを削除し、S3 のデータセットをすばやく調整
• 移行 (transition): ファイル、パーティション、またはテーブルを下位の S3 ストレージクラスに移行可能
• 結合 (merge): プライマリキーに基づいて S3、Redshift、DynamoDB、またはJDBC ソースのデータを表す複数の Glue DynamicFrame を結合可能
https://aws.amazon.com/jp/about-aws/whats-new/2020/01/aws-glue-adds-new-transforms-apache-spark-applications-datasets-amazon-s3/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
25
Glue Spark ETL ジョブ、カスタム JDBC ドライバーに対応
https://aws.amazon.com/jp/about-aws/whats-new/2019/11/aws-glue-now-enables-you-to-bring-your-own-jdbc-drivers-to-your-glue-spark-etl-jobs/
コネクション種別 対応データストア
JDBC Amazon Redshift
Amazon Aurora
Microsoft SQL Server
MySQL
Oracle
PostgreSQL
Amazon RDS
Amazon Redshift
Amazon DocumentDB
MongoDB
ネイティブで対応しているデータストア
データストア
MySQL 8.x
Oracle 18
DB2
Snowflake
その他
カスタムJDBCを利用する例
• Glue ジョブから複数の JDBC ドライバーを使用可能• 異なるデータストア間でのデータ移行も可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
26
Preview: Reduced start times for Spark jobs
Glue Spark ジョブの起動に要する時間を大幅に短縮
- 従来、Glue 0.9/1.0 ではコールドスタートに 8分程度かかっていた
- 新しい Glue 2.0 では 1分未満に
time
Start-up time Execution time
Execution time
Glue 1.0
Glue 2.0
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
27
Amazon Athena updates
© 2020, Amazon Web Services, Inc. or its Affiliates.
Amazon Athena
クエリーごとの課金
クエリー単位のデータスキャン量に応じた課金体系
スキャン対象となるデータの圧縮により、クエリ単位のコストを
30~90%削減可能
ストレージはS3
ANSI準拠のSQL
JDBC/ODBC ドライバー
複数のフォーマット、圧縮タイプ、複雑な結合とデータ
タイプ
SQL
サーバレス: インフラストラクチャーおよびアドミンは不要
Amazon QuickSightとも統合
簡単即時にクエリー
セットアップ費用ゼロ
S3 をポイントしてクエリを開始
サーバレス、インタラクティブ・クエリーサービス
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
29
Amazon Athena updates
• 機能拡張アップデート• 外部メタストアに対応
• Partition Projection
• INSERT INTO クエリに対応
• 運用関連機能アップデート
• Athena Workgroups update
• イベント通知機能
• メトリクスの追加
• aws:CalledVia 条件キー
• Preview 機能紹介
• Federated Query
• UDF
• Machine Learning (ML) with Amazon Athena
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
30
機能拡張アップデート
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
31
外部メタストアに対応
• ご自身でホストする Hive Metastore をビッグデータ環境の共通メタデータカタログとして使っている場合に、そのメタデータカタログを Athena に 登録・利用することが可能に
• 既存の Hive Metastore 資産を AWS Glue Data Catalog に移行する必要がなくなる
• 外部メタストアへの接続には、Lambda 関数として実行されるコネクター(Athena Data Connector for External Hive Metastore) を利用する
https://docs.aws.amazon.com/athena/latest/ug/connect-to-data-source-hive.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
32
Partition Projection
Partition Projection を使用すると、非常に多くのパーティションがあるテーブルに対するクエリ処理を高速化し、パーティション管理を自動化することが可能
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/partition-projection.html
• パーティションプルーニングでは、メタデータを収集し、クエリに適用されるパーティションにだけに処理が実行されるので、多くの場合、クエリが高速化する
SELECT
month
, action_category
, action_detail
, COUNT(user_id)
FROM
action_log
WHERE
year = 2016
AND month >= 4
AND month < 7
GROUP BY
month
, action_category
, action_detail
以下の Amazon S3 パスだけが読み込まれる
s3://athena-examples/action-log/year=2016/month=04/day=01/
s3://athena-examples/action-log/year=2016/month=04/day=02/
s3://athena-examples/action-log/year=2016/month=04/day=03/
...
s3://athena-examples/action-log/year=2016/month=06/day=30/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
33
Partition Projection
Partition Projection を使用すると、非常に多くのパーティションがあるテーブルに対するクエリ処理を高速化し、パーティション管理を自動化することが可能
Query Planning Time
API Call• しかしながら、テーブルに非常に多くの
パーティションがある場合、AWS Glue Data Catalog に対するパーティション取得API(GetPartitions) の呼び出しがクエリパフォーマンスに影響する可能性が生じる
Partition Projection
• Partition Projection を利用するとパーティション情報を Athena 自身で計算できるようになるため、GetPartitions 呼び出しの影響を回避し、パーティションプルーニングによるクエリ高速化の恩恵を享受できるようになる
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
34
Partition Projection
ユースケース• 非常に多くのパーティションがあるテーブルに対するクエリが思ったほどすぐに完了しない場合
• データに新しいパーティションが作成されたとき、定期的にパーティションをテーブルに追加している場合
• 非常に多くのパーティション化されたデータが S3 に保存されていて、メタデータストアで管理するのが現実的でなく、クエリで参照する対象のデータがほんの一部の場合
Projection 可能なパーティション構造Partition Projection はパーティションが予測可能なパターンに従う場合に利用する
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/partition-projection.html
Projection
Typeパターン 例
整数 整数の連続シーケンス [1, 2, 3, 4, ..., 1000] や [0500, 0550, ..., 2500] など
日付日付/日時の連続シーケンス
[20200101, 20200102, ..., 20201231]、[1-1-2020 00:00:00, 1-1-2020 01:00:00, ..., 12-31-2020 23:00:00] など
列挙値 列挙値の有限セット 空港コードや AWS リージョンなど
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
35
Partition Projection – 設定例
• テーブル作成時に Partition Projection を設定しておくと、設定に基づいてパーティションが存在する場所を Athena に通知することが可能
• 次の CREATE TABLE の設定例では、日付範囲の上限に NOW を使用することで、1時間毎に新しいデータが自動的にクエリ可能になる
...
LOCATION "s3://bucket/prefix/"
PARTITIONED BY (
datehour STRING
)
TABLE PROPERTIES (
"projection.enabled" = "true",
"projection.datehour.type" = "date",
"projection.datehour.range" = "2018/01/01/00,NOW",
"projection.datehour.format" = ""yyyy/MM/dd/HH",
"projection.datehour.interval" = "1",
"projection.datehour.interval.unit" = "HOURS",
"storage.location.template" = "s3://bucket/prefix/${datehour}”
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/partition-projection-kinesis-firehose-
example.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
36
Partition Projection – 制限事項
• Projection されたパーティションに空のパーティションが多すぎる場合、従来の AWS Glue パーティションに比べてパフォーマンスが低下する可能性がある
• Projection パーティションの半分以上が空の場合は、従来のパーティション利用を推奨
• Partition Projection は、Athena を通じてテーブルがクエリされた場合にのみ使用できます
• Amazon Redshift Spectrum または Amazon EMR などの別のサービスを通じて同じテーブルが読み取られた場合、標準パーティションメタデータが使用されます
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
37
INSERT INTO クエリに対応
• クエリ結果をもとに、既存のテーブルにデータを追加可能
• SELECT クエリステートメント、またはステートメントの一部として提供される VALUES のセットに基づいて、テーブルに新しい行を挿入
• 挿入されるテーブルのデータ形式にデータが変換されるため、INSERT
INTO クエリをデータ形式変換用のクエリとして利用可能
INSERT INTO destination_table
SELECT select_query FROM source_table_or_view
INSERT INTO destination_table [(col1,col2,...)]
VALUES (col1value,col2value,...)[,
(col1value,col2value,...)][,
...]
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
38
INSERT INTO クエリに対応
INSERT INTO 句で以下のようにパーティションを追加することも可能
1. CREATE EXTERNAL TABLE で、s3://MY_BUCKET/service_a/ にパーティションを設定したテーブル table_service_a を作成
2. 日次受信データ用のテーブル tmp_table_service_a を作成
3. INSERT INTO で tmp_table_service_a のデータを(処理した上で) table_service_a に追加
4. tmp_table_service_a を DELETE TABLE で削除
5. 2-4 を日次で実行
制約事項• INSERT INTO できるパーティションの最大数は 100
• バケット化されたテーブルは未サポート
• サポートされるデータ形式は Avro/JSON/ORC/Parquet/テキストファイル
(対応する Serde の詳細はドキュメントを参照)
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/insert-into.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
39
(ユースケース) ETL パイプラインを Athena で構築
連携先サービスから定期的に送られてくるデータに対して、INSERT INTO 句を用いて継続的なデータ変換を行い、効率的にクエリ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
40
運用関連機能アップデート
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
41
Athena Workgroups が AWS CloudFormation をサポート
• Athena Workgroups を利用すると利用量とコストの管理が可能に
• 同一アカウント内で、仮想的なワークグループを作成することで、ワークグループごとに下記設定を実施可能
• クエリワークロードの分離
• クエリメトリクスの分離
• クエリ毎のスキャン量上限設定
• スキャン量が一定を超えたらアラームをあげることも可能
• Athena の運用管理に欠かせない Workgroups 機能が CloudFormation 経由で操作可能に
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/user-created-workgroups.html
https://aws.amazon.com/jp/about-aws/whats-new/2020/03/amazon-athena-adds-support-for-managing-athena-workgroups-using-aws-cloudformation/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
42
Amazon EventBridge 経由でのイベント通知に対応
• EventBridge (旧名 Amazon CloudWatch Events) を使用して、クエリの状態に関するリアルタイムの通知を受け取ることが可能に
• クエリの状態が移行する(たとえば、実行中から成功またはキャンセルなど)と、Athena はそのクエリ状態移行に関する情報を含むイベントを EventBridge に発行する
• 発行されたイベントに対応したルールを準備することで、下記のようなアクションを自動化することが可能
• クエリが成功した場合に Lambda 関数を呼び出して後続処理を実行
• クエリが失敗した場合にアラート通知を発行する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
43
Amazon Athena が4つの新しいメトリクスを追加
Athena の性能を把握するのに役立つ 4 つのクエリメトリクスが追加
• Query Planning Time
− クエリの計画を立てるためにかかる時間
− データソースからテーブルパーティションを取得する時間も含まれる
• Query Queuing Time
− クエリがリソースを待ってキューに並んでいた時間
• Service Processing Time
− クエリエンジンがその実行を完了した後に結果を書き込むのにかかる時間
• Total Execution Time
− クエリを実行するのに Athena が費やした全体の時間
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
44
AWS IAM の aws:CalledVia 条件キーを使用したS3 バケットのデータのクエリに対応
• これまで、制限的な S3 バケットポリシーに対し、Athena のアクセスを許可する方法がなかった為、バケットポリシーで制限された S3 バケットからデータをスキャンしようとすると、そのクエリは失敗していた
• 今回のリリースにより、既存のバケットポリシーに aws:CalledVia キーを設定することで、Athena がユーザーに代って S3 バケット内のデータをスキャン可能となり、クエリの実行が可能に
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
45
(ユースケース)
AWS Glue Data Catalog のリソースベースポリシー
• AWS Glue Data Catalog を用いることで、IAM ユーザーやロールに対して、テーブル単位でのアクセス権限を設定することが可能
• AWS Glue Data Catalog はメタデータの管理しか行わないので、別途 Amazon S3 へのアクセスをバケットポリシーで制限する必要がある
• 制限されたバケットに対する Athena からのアクセスは aws:CalledVia 条件キーで制御する
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
46
Preview 機能紹介
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
47
Amazon Athena Federated Query
• 様々なデータソースに対して SQL クエリを実行可能
• 複数のデータソースを横断的に分析
• AWS Lambdaで動作する Athena Data Source Connectorsを利用して実行される
• 標準のコネクタ• Amazon DynamoDB
• Amazon Redshift
• Apache HBase
• MySQL
• PostgreSQL など
• カスタムデータソース対するコネクタ• Athena Query Federation SDK を利用して実装
• 対応リージョン
• バージニア、ムンバイ、アイルランド、オレゴン フェデレーテッド・クエリの例
https://github.com/awslabs/aws-athena-query-federation
https://aws.amazon.com/jp/blogs/news/query-any-data-source-with-amazon-athenas-new-federated-query/※コネクター実装チュートリアル動画も掲載されています(英語)
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
48
UDF (User Defined Function)
• ユーザ独自のスカラー関数を UDF (User Defined Function) として定義して、SQL クエリで呼び出すことが可能
• データの圧縮や解凍、機密データの編集、カスタマイズされた復号の適用など独自の処理を実行可能
• UDF の実装方法: Athena Query Federation SDK を利用して Java で実装(UDF は Lambda 関数として実行される)
• 対応リージョン: バージニア、ムンバイ、アイルランド、オレゴン
https://docs.aws.amazon.com/athena/latest/ug/querying-udf.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
49
UDFs がない場合の課題
• UDFs がないと、データの前処理または後処理が難しくなりがち
• 特定の列へのアクセス制御のために生データの複製が必要になり得る
• カスタムコードの実行と、分析のための SQL クエリの利用と、複数のアプリケーションの学習と使用を強いられ得る
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
50
Athena クエリ内でのカスタムファンクションの実行
• AWS Lambda を活用した UDFs
• ネットワークコールをサポート
• SELECT、または、FILTER 句での UDF 呼び出しをサポート
• Athena がパフォーマンスを最適化するので、処理ロジックに専念できる
https://github.com/awslabs/aws-athena-query-federation
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
51
Athena UDFs コードサンプル
• シンプル
• コードを書いて、
• デプロイして、
• クエリから呼び出す
• Scalar 関数のみサポート
• AWS Lambda を活用
UDF Lambda コード
Athena クエリ
USING FUNCTION compress(col1 VARCHAR)
RETURNS VARCHAR TYPE
LAMBDA_INVOKE WITH (lambda_name = 'MyAthenaUDFLambda')
SELECT
compress('StringToBeCompressed');
public class MyUserDefinedFunctions
extends UserDefinedFunctionHandler {
…
public String compress(String input) {
…
return Base64.getEncoder().encodeToString(compressedBytes);
}
…
}
https://github.com/awslabs/aws-athena-query-federation
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
52
Machine Learning (ML) with Amazon Athena
• Athena SQL クエリで SageMaker 機械学習 (ML) モデルを呼び出し、推論を実行可能
• 異常検出やコホート分析、販売予測などの複雑な作業が SQL クエリで関数を呼び出す感覚で利用できる
• 対応リージョン:バージニア、ムンバイ、アイルランド、オレゴン
https://docs.aws.amazon.com/ja_jp/athena/latest/ug/querying-mlmodel.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
53
Athena に ML 機能があると嬉しいわけ
多くのエンジニアは、
SQL 習熟度 > ML 習熟度
SQL 習熟度 > Python 習熟度
SQL 習熟度 > Java 習熟度
...
...
SQL クエリで機械学習を利用した推論を実行することに利点がある
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
54
SQL クエリ内で、機械学習による推論を実行する
• ML モデルを Amazon SageMaker に一度デプロイし、そして、何度も利用する
• 任意の場所にあるデータに対して推論を実行
• 推論を実行可能にするために、アプリケーションを構築する必要がない
• 追加のセットアップは不要
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
55
機械学習の利用例
• 疑わしいアクティビティと関連する IP アドレスをアプリケーションログから見つける
• 収益に異常(プラス/マイナス)がある商品の検索
• 取引記録から、不正行為の疑いのあるものを見つける
• 企画提案された新しいビデオゲームがヒットするかどうかを予測する
https://aws.amazon.com/blogs/big-data/prepare-data-for-model-training-and-invoke-machine-learning-models-with-amazon-athena/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
56
推論を実行するクエリの例
USING FUNCTION predict(platform int, genre int, critic_score int, user_score int, rating int)
RETURNS double TYPE
SAGEMAKER_INVOKE_ENDPOINT
WITH (sagemaker_endpoint='xgboost-2019-11-22-00-52-22-742'),
USING FUNCTION normalize_genre(value VARCHAR)
RETURNS int TYPE
LAMBDA_INVOKE WITH (lambda_name='VideoNormalization’),
SELECT predict(platform, genre, critic_score, user_score, rating), name
FROM
(SELECT name,
normalize_genre(genre) AS genre,
critic_score,
user_score,
FROM video_game_data.video_games);
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
57
Amazon EMR updates
© 2020, Amazon Web Services, Inc. or its Affiliates.
Amazon EMR
Hadoop クラスタを数分で立ち上げ、API コールで簡単にスケール
S3 上のデータを読み込んでジョブを実行し、結果を S3 に出力
Spark、Hive、Presto、HBase などのミドルウェアを利用可能
ローコスト
EC2スポットとリザーブドインスタンスでコストを50~80%削減
フレキシブルな秒単位の課金
S3をストレージとして利用
EMRFSコネクタを使用し、S3上のデータを高パフォーマンス
で安全に処理
最新バージョン
30日以内に最新のオープンソースフレームワークに更新
フルマネージド
クラスタのセットアップ、ノードのプロビジョニング、クラスタのチューニングは不要
簡単
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
59
Amazon EMR updates
• Amazon EMR 6.0.0 関連機能
• EMR 6.0.0 概要
• Docker Support
• Hive LLAP Support
• YARN Timeline Server/Tez UI 関連アップデート
• アップデート情報
• Managed Scaling
• EMR Notebooks update
• VPCエンドポイント Support
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
60
Amazon EMR 6.0.0 機能紹介
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
61
EMR 6.0.0 概要
• Hadoop 3.2.1
• HDFS のイレージャーコーディング — データの耐久性を向上させつつHDFSのストレージコストを軽減(x3 x1.4)
• YARN リソースタイプ — 追加のリソースタイプやスケジューラなどを設定可能
• YARN Docker ランタイムのサポート
• Hive LLAP のサポート
• Amazon Linux 2
• Amazon Correto JDK 8
• Scala 2.12
• Python 3
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
62
Docker Support
• クラスターを共有利用すると、ユーザごとに利用するライブラリやパッケージの依存関係が生じるため、クラスターを分けるなどの対処が必要でした
• Hadoop 3.0 で Docker がサポートされたことにより、個々のジョブやノートブックの依存関係などをパッケージ化し、管理することが可能
• Docker registries として Docker Hub / Amazon ECR を利用可能
https://aws.amazon.com/jp/blogs/big-data/simplify-your-spark-dependency-management-with-
docker-in-emr-6-0-0/
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
63
Hive LLAP Support
• Hive の Live Long and Process (LLAP) 機能をサポート
• LLAP では、永続的なデーモンによるインテリジェントなメモリ内キャッシングを使用し、以前のデフォルトの Tez コンテナ実行モードと比較してクエリのパフォーマンスが向上
https://aws.amazon.com/jp/blogs/big-data/apache-hive-is-2x-faster-with-hive-llap-on-emr-6-0-0/XX
6 ノードの c4.8xlarge EMR クラスターで 3 TB の Apache Parquet データセットに 70 個の TCP-DS クエリを使用し、合計実行時間と相乗平均を EMR リリース 6.0.0 と 5.29.0 からの結果とで比較
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
64
Hive LLAP Support - Why Hive LLAP
• Hive エコシステム
• 学習コスト
• 既存のHive SQLやHiveServer2などの他のHiveツール、およびHive用のJDBCドライバとの互換性
• セキュリティ
• HiveServer2を使用した認証と認可(SQL標準ベースの認可)
• Fine Grained Access Control (列・レコード)
• パフォーマンス
• Hiveのベクトル化機能を使用したクエリの高速化
• Hive オプティマイザー• 複数の小さなファイルをマージする
• 結合やグループ化のためのReducerの数を自動的に決定するなど
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
65
永続的な YARN Timeline Server および Tez UI へのEMR コンソールアクセス
• これまではマスターノードで稼働する YARN Timeline Server / Tez UI にアクセスするのが手間で、クラスターが終了すると利用できなくなる
• 今回のアップデートで、EMR コンソールから簡単にアクセス可能となり、クラスターを終了した後も、YARN Timeline Server/Tez UI が利用可能に
• YARN Timeline Server / Tez UI
• Hadoop 上の分散アプリケーションのログを可視化し、直感的な UI を提供することで、アプリケーションの履歴管理や監視、デバッグエクスペリエンスを向上させるオープンソースアプリケーション
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
66
永続的な YARN Timeline Server および Tez UI へのEMR コンソールアクセス
クラスター詳細画面
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
67
アップデート情報
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
68
Managed Scaling
• これまでのオートスケーリング機能はインスタンスグループでしか利用できず、また、スケーリングポリシーを利用者が設定する必要がありました
• 今回のリリースにより、オートスケーリングがマネージド化され、インスタンスフリートでもオートスケーリング機能が利用可能(Amazon EMR バージョン5.30.0 以降)
• マネージドスケーリング機能を有効化し、下記パラメータを設定するだけで利用可能
[最小] – ユニットの下限
[最大] – ユニットの上限
オンデマンドの制限 (オプション) - オンデマンドユニット数の上限
クラスター構成種別 ユニット数定義
インスタンスグループ インスタンス、または、vCPU コア
インスタンスフリート インスタンスフリートユニット
https://docs.aws.amazon.com/ja_jp/emr/latest/ManagementGuide/emr-managed-scaling.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
69
Managed Scaling – メトリクス
• クラスターでマネージドスケーリングが有効になっている場合に、1 分単位のデータを含む高解像度のメトリクスを公開
• マネージドスケーリングによって制御されるすべてのサイズ変更開始/完了イベントをAmazon EMR コンソール/Amazon CloudWatch コンソールで表示可能
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
70
EMR Notebooks から EMR クラスターに直接、カスタムカーネルと Data Science ライブラリをインストール可能に
• EMR Notebooks は、Jupyter ベースのサーバレスノートブックです
• カスタムカーネルやライブラリの導入に必要だった複数のインストールプロセスが不要となり、EMR Notebook から直接クラスターに導入可能に
https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-notebooks-installing-libraries-and-kernels.html
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
71
VPC エンドポイントをサポート
• Amazon EMR はインターネットを経由せずに Amazon Virtual Private
Cloud (Amazon VPC) 内で Amazon EMR にアクセス可能に
• インターフェイス VPC エンドポイントを使用すると、VPC と EMR API間の通信は完全に AWS ネットワーク内で実施されます
• VPC エンドポイントのポリシーを作成して、以下を指定できます
• アクションを実行できるプリンシパル
• 実行可能なアクション
• このアクションを実行できるリソース
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark.
72
まとめ
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
73
まとめ
データレイクを構成する下記 AWS サービスについてUpdate 情報をご紹介しました
• AWS Glue updates
• Amazon Athena updates
• Amazon EMR updates
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
74
内容についての注意点
• 本資料では 2020 年 6 月 18 日時点のサービス内容および価格についてご説明しています.最新の情報は AWS 公式ウェブサイト (http://aws.amazon.com) にてご確認ください。
• 資料作成には十分注意しておりますが,資料内の価格とAWS公式ウェブサイト記載の価格に相違があった場合,AWS公式ウェブサイトの価格を優先とさせていただきます.
• 価格は税抜表記となっています.日本居住者のお客様には別途消費税をご請求させていただきます.
• AWS does not offer binding price quotes. AWS pricing is publicly available and is subject to change in accordance with the AWS Customer Agreement available at http://aws.amazon.com/agreement/. Any pricing information included in this document is provided only as an estimate of usage charges for AWS services based on certain information that you have provided. Monthly charges will be based on your actual use of AWS services, and may vary from the estimates provided.
75
関連セミナーのご案内• 好評につき再演決定!【オンラインセミナー】「AWSではじめるデータレ
イク」出版記念 - データレイクはじめの一歩 ~データレイク概要、DWH
やRDBとの違い、AWSのデータレイクサービス~
• 5/28の第1回講演を見逃した方はぜひご参加ください
• 2020 年 6 月 25 日(木) 開演:17:00 ~ 18:00
• https://aws-seminar.smktg.jp/public/seminar/view/2740
• [オンライン開催]「AWSではじめるデータレイク」出版記念 AWS Data
Lake ハンズオンセミナー
• 2020 年 7 月 1 日(水) 開演:13:00 ~ 17:45
• AWS アナリティクスサービスを使った分析パイプラインの構築を通して、「データレイク」と「ビッグデータ分析基盤の構築」を実際にご参加者に体験していただきます
• 申し込みページは近日公開されます
76
アンケート記入のお願い
https://bit.ly/3hAyXIFもしくは
https://amazonmr.au1.qualtrics.com/jfe/form/S
V_418MiPMsc8fx5c1
アンケートにお答えいただいた方には
本日の資料を後日ご提供させていただきます
© 2020, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
77
Q&A