© 2020, Amazon Web Services, Inc. or its Affiliates.
Noritaka Sekiyama
Sr. Big Data Architect, AWS Glue & Lake Formation
2020/11/20
AWS で Presto を
徹底的に使いこなすワザ
© 2020, Amazon Web Services, Inc. or its Affiliates.
⾃⼰紹介
関⼭ 宜孝
Sr. Big Data Architect
AWS Glue & Lake Formation
• GlueとLake Formationの
ユーザーに近い部分の開発を担当
• 5年間 AWS サポートにて技術⽀援を担当
• 2019年からプロダクト開発チームにジョイン
@moomindani moomindaniNoritakaS-AWS
Forum
© 2020, Amazon Web Services, Inc. or its Affiliates.
本セッションについて
• AWS x Presto
• Presto x Amazon EMR
• Presto x Amazon S3
• Presto x AWS Glue
• Presto x AWS Auto Scaling
• Presto on AWS の使い分け
AWS で Presto を徹底的に使いこなすワザを習得する
• Presto 視点で AWS の各種サービスを使いこなす⽅法
• Presto on AWS を⽬的に合わせて使い分ける⽅法
© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS x Presto
Amazon EC2 Amazon EMR Amazon Athena
Amazon S3 AWS
Glue
PrestoDB 0.232
PrestoSQL 338
PrestoDB 0.172 or 0.217
データ メタデータ
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto x Amazon EMR
© 2020, Amazon Web Services, Inc. or its Affiliates.
EMR 6.1.0 にて Presto SQL をサポート
• 従来の PrestoDB に加え、新たに PrestoSQL を選択可能に
© 2020, Amazon Web Services, Inc. or its Affiliates.
EMR 6.1.0 における Presto の動作
EMR Master Node
Name Node
Presto
Coordinator
EMR Task Node
Presto Worker
Disk
EMR Core Node
Data
Node
Presto Worker
Disk
EMR Core Node
Data
Node
Presto Worker
EMR Cluster
EMR Task Node
Presto Worker
© 2020, Amazon Web Services, Inc. or its Affiliates.
EMR 6.1.0 における Presto の動作
Task
Core
Master
© 2020, Amazon Web Services, Inc. or its Affiliates.
EMR 6.1.0 における Presto の動作
$ presto-cli --catalog hive
presto> select * from system.runtime.nodes;
node_id | http_uri | node_version | coordinator | state
---------------------+---------------------------+--------------+-------------+--------
i-0cb86cde1bbe34782 | http://172.31.21.240:8889 | 338 | false | active
i-0f2f12645011b0715 | http://172.31.18.88:8889 | 338 | false | active
i-0de5119f5f5d15bf2 | http://172.31.27.4:8889 | 338 | true | active
i-0a71e27153a1d3102 | http://172.31.30.217:8889 | 338 | false | active
i-056355b68a53429df | http://172.31.24.68:8889 | 338 | false | active
(5 rows)
Query 20201110_081259_00008_4ut3q, FINISHED, 2 nodes
Splits: 17 total, 17 done (100.00%)
0.23 [5 rows, 266B] [21 rows/s, 1.12KB/s]
Master
Core
Task
© 2020, Amazon Web Services, Inc. or its Affiliates.
クエリの実⾏
• presto-cli
presto> select origin, count(*) as total_departures from flights.flights_crawledcsv
-> group by origin
-> order by total_departures DESC;
origin | total_departures
--------+------------------
ATL | 373197
ORD | 231723
DEN | 216520
LAX | 198062
DFW | 173121
SFO | 163608
PHX | 144239
LAS | 138875
IAH | 134806
MSP | 125699
DTW | 120951
SEA | 120923
MCO | 115478
EWR | 111412
© 2020, Amazon Web Services, Inc. or its Affiliates.
クエリの実⾏
• JDBC
• REST API
jdbc:presto://example.net:8080/hive/sales
$ curl -XPOST http://localhost:8889/v1/statement 
--data "SELECT 1” 
--header "X-Presto-User: hadoop" 
--header "X-Presto-Schema: default" 
--header "X-Presto-Time-Zone:UTC" 
--header "X-Presto-Catalog: hive"
© 2020, Amazon Web Services, Inc. or its Affiliates.
クエリの実⾏
• EMR Step
© 2020, Amazon Web Services, Inc. or its Affiliates.
クエリの実⾏
• EMR Step
© 2020, Amazon Web Services, Inc. or its Affiliates.
クエリの実⾏
• EMR Parallel Step with AWS Step Functions
{
"Comment": "EMR Step",
"StartAt": "Presto_Query_One",
"States": {
"Presto_Query_One": {
"Type": "Task",
"Resource": "arn:aws:states:::elasticmapreduce:addStep.sync",
"Parameters": {
"ClusterId.$": "$.ClusterId",
"Step": {
"Name": "The first query",
"ActionOnFailure": "CONTINUE",
"HadoopJarStep": {
"Jar": "command-runner.jar",
"Args": [
"presto-cli",
"--catalog",
"hive",
"--execute",
"SELECT 1"
]
}
}
},
"Next": "ParallelQuery",
"ResultPath": null
},
"ParallelQuery": {
"Type": "Parallel",
"End": true,
"Branches": [
{
"StartAt": "Presto_Query_Two",
"States": {
"Presto_Query_Two": {
"Type": "Task",
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto Server の追加
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto Server の追加
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto Server の追加
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto の設定変更
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto x Amazon S3
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto から Amazon S3 へのアクセス
• EMRFS
• EMR 5.12.0 以降および 6.1.0 以降はデフォルトで
Amazon S3 へのアクセスに EMRFS を利⽤
• 暗号化
• IAM ロールによるアクセス
• PrestoS3FileSystem
• OSS PrestoDB/Presto SQL, およびEMR 5.12.0 未満では
PrestoS3FileSystem を利⽤
• EMR 5.12.0 以降および 6.1.0 以降でも切り替え可能
• https://prestodb.io/docs/current/connector/hive.html#amazon-s3-configuration
• https://prestosql.io/docs/current/connector/hive-s3.html
© 2020, Amazon Web Services, Inc. or its Affiliates.
S3 SELECT Pushdown
• S3 SELECT
• S3 上のファイルにクエリする Amazon S3 の機能
© 2020, Amazon Web Services, Inc. or its Affiliates.
S3 SELECT Pushdown
• Presto における S3 SELECT Pushdown
• Presto から S3 へのデータ参照に S3 SELECT を使⽤し、
Projection operation (e.g. SELECT)と Predicate operation
(e.g. WHERE) を削減することで計算量を最適化
• ⾮圧縮, gzip, bzip2 の CSV ファイルをサポート
[
{
"classification": "presto-connector-hive",
"properties": {
"hive.s3select-pushdown.enabled": "true",
"hive.s3select-pushdown.max-connections": "500"
}
}
© 2020, Amazon Web Services, Inc. or its Affiliates.
S3 SELECT Pushdown
• 有効なシーン
• データセットの半分以上をフィルタアウトするクエリ
• Presto と Amazon S3 の間のネットワーク帯域が⼗分な環境
• Presto と S3 SELECT の両⽅でサポートしているデータタイプ
をもつカラムを使う場合
• Timestamp, Real, Double は S3 SELECT Pushdown ⾮対応
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto x AWS Glue
© 2020, Amazon Web Services, Inc. or its Affiliates.
Glue Data Catalog との連携
• Presto Hive Connector にて Hive メタストアサービスに加えて
Glue Data Catalog に対応
• メタストアを永続化したい場合
• 複数のクラスタ、サービス、アプリケーションなどでメタスト
アを共有したい場合
[
{
"Classification": "presto-connector-hive",
"Properties": {
"hive.metastore": "glue"
}
}
]
© 2020, Amazon Web Services, Inc. or its Affiliates.
Glue Data Catalog との連携
• 制限事項あり
• テーブル名のリネームには⾮対応
• Column statistics には⾮対応
• Hive Authorization には⾮対応
• https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-presto-glue.html#emr-presto-
glue-knownissues
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto x AWS Auto Scaling
© 2020, Amazon Web Services, Inc. or its Affiliates.
Graceful Decommission
• Auto Scaling のスケーリング操作時に猶予期間を設定
• Presto がデコミッション中のノードに新しいタスクをスケ
ジューリングしないようにする
• Presto が削除対象のノードで実⾏中のタスクを完了できるよう
にする
[
{
"classification": "presto-config",
"properties": {
"graceful-shutdown-timeout": "1800s"
}
}
]
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
Presto on AWS の使い分け
Presto on EC2 Presto on EMR Athena
Presto ソフトウェア PrestoSQL or
PrestoDB
PrestoSQL or
PrestoDB
PrestoDB のみ
バージョン 任意 PrestoSQL 338
PrestoDB 0.232
PrestoDB 0.172 or 0.217
AWS マネジメントコンソー
ルからのクエリ
× ×
※Step で代替可能
◯
Presto UI / クエリプラン ◯ ◯ ×
クラスタプロビジョニング ⼿動 ⾃動 不要
クラスタ運⽤管理 必要 必要 不要
ノード数 任意 任意 設定不可
オートスケーリング △ ◯ -
コスト EC2 利⽤料 EC2 利⽤料
EMR 利⽤料
Athena クエリ利⽤料
設定カスタマイズ ◯ ◯ ×
主な利⽤シーン 任意のバージョンの組
み合わせが必要な場合
ノード数や設定などを⾃由に
カスタマイズしたい場合
他の Hadoop/Spark アプリ
ケーションと併⽤したい場合
サーバーレスでクエリしたい場合
ML Query, Partition Projection
などの Athena 固有機能を使いた
い場合
© 2020, Amazon Web Services, Inc. or its Affiliates.
おわりに
• AWS x Presto
• EMR
• S3
• Glue
• Auto Scaling
• Presto on AWS の使い分け
AWS で Presto を徹底的に使いこなすワザを習得する
• Presto 視点で AWS の各種サービスを使いこなす⽅法
• Presto on AWS を⽬的に合わせて使い分ける⽅法

AWS で Presto を徹底的に使いこなすワザ

  • 1.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Noritaka Sekiyama Sr. Big Data Architect, AWS Glue & Lake Formation 2020/11/20 AWS で Presto を 徹底的に使いこなすワザ
  • 2.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. ⾃⼰紹介 関⼭ 宜孝 Sr. Big Data Architect AWS Glue & Lake Formation • GlueとLake Formationの ユーザーに近い部分の開発を担当 • 5年間 AWS サポートにて技術⽀援を担当 • 2019年からプロダクト開発チームにジョイン @moomindani moomindaniNoritakaS-AWS Forum
  • 3.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. 本セッションについて • AWS x Presto • Presto x Amazon EMR • Presto x Amazon S3 • Presto x AWS Glue • Presto x AWS Auto Scaling • Presto on AWS の使い分け AWS で Presto を徹底的に使いこなすワザを習得する • Presto 視点で AWS の各種サービスを使いこなす⽅法 • Presto on AWS を⽬的に合わせて使い分ける⽅法
  • 4.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. AWS x Presto Amazon EC2 Amazon EMR Amazon Athena Amazon S3 AWS Glue PrestoDB 0.232 PrestoSQL 338 PrestoDB 0.172 or 0.217 データ メタデータ
  • 5.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto x Amazon EMR
  • 6.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. EMR 6.1.0 にて Presto SQL をサポート • 従来の PrestoDB に加え、新たに PrestoSQL を選択可能に
  • 7.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. EMR 6.1.0 における Presto の動作 EMR Master Node Name Node Presto Coordinator EMR Task Node Presto Worker Disk EMR Core Node Data Node Presto Worker Disk EMR Core Node Data Node Presto Worker EMR Cluster EMR Task Node Presto Worker
  • 8.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. EMR 6.1.0 における Presto の動作 Task Core Master
  • 9.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. EMR 6.1.0 における Presto の動作 $ presto-cli --catalog hive presto> select * from system.runtime.nodes; node_id | http_uri | node_version | coordinator | state ---------------------+---------------------------+--------------+-------------+-------- i-0cb86cde1bbe34782 | http://172.31.21.240:8889 | 338 | false | active i-0f2f12645011b0715 | http://172.31.18.88:8889 | 338 | false | active i-0de5119f5f5d15bf2 | http://172.31.27.4:8889 | 338 | true | active i-0a71e27153a1d3102 | http://172.31.30.217:8889 | 338 | false | active i-056355b68a53429df | http://172.31.24.68:8889 | 338 | false | active (5 rows) Query 20201110_081259_00008_4ut3q, FINISHED, 2 nodes Splits: 17 total, 17 done (100.00%) 0.23 [5 rows, 266B] [21 rows/s, 1.12KB/s] Master Core Task
  • 10.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. クエリの実⾏ • presto-cli presto> select origin, count(*) as total_departures from flights.flights_crawledcsv -> group by origin -> order by total_departures DESC; origin | total_departures --------+------------------ ATL | 373197 ORD | 231723 DEN | 216520 LAX | 198062 DFW | 173121 SFO | 163608 PHX | 144239 LAS | 138875 IAH | 134806 MSP | 125699 DTW | 120951 SEA | 120923 MCO | 115478 EWR | 111412
  • 11.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. クエリの実⾏ • JDBC • REST API jdbc:presto://example.net:8080/hive/sales $ curl -XPOST http://localhost:8889/v1/statement --data "SELECT 1” --header "X-Presto-User: hadoop" --header "X-Presto-Schema: default" --header "X-Presto-Time-Zone:UTC" --header "X-Presto-Catalog: hive"
  • 12.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. クエリの実⾏ • EMR Step
  • 13.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. クエリの実⾏ • EMR Step
  • 14.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. クエリの実⾏ • EMR Parallel Step with AWS Step Functions { "Comment": "EMR Step", "StartAt": "Presto_Query_One", "States": { "Presto_Query_One": { "Type": "Task", "Resource": "arn:aws:states:::elasticmapreduce:addStep.sync", "Parameters": { "ClusterId.$": "$.ClusterId", "Step": { "Name": "The first query", "ActionOnFailure": "CONTINUE", "HadoopJarStep": { "Jar": "command-runner.jar", "Args": [ "presto-cli", "--catalog", "hive", "--execute", "SELECT 1" ] } } }, "Next": "ParallelQuery", "ResultPath": null }, "ParallelQuery": { "Type": "Parallel", "End": true, "Branches": [ { "StartAt": "Presto_Query_Two", "States": { "Presto_Query_Two": { "Type": "Task",
  • 15.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto Server の追加
  • 16.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto Server の追加
  • 17.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto Server の追加
  • 18.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto の設定変更
  • 19.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto x Amazon S3
  • 20.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto から Amazon S3 へのアクセス • EMRFS • EMR 5.12.0 以降および 6.1.0 以降はデフォルトで Amazon S3 へのアクセスに EMRFS を利⽤ • 暗号化 • IAM ロールによるアクセス • PrestoS3FileSystem • OSS PrestoDB/Presto SQL, およびEMR 5.12.0 未満では PrestoS3FileSystem を利⽤ • EMR 5.12.0 以降および 6.1.0 以降でも切り替え可能 • https://prestodb.io/docs/current/connector/hive.html#amazon-s3-configuration • https://prestosql.io/docs/current/connector/hive-s3.html
  • 21.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. S3 SELECT Pushdown • S3 SELECT • S3 上のファイルにクエリする Amazon S3 の機能
  • 22.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. S3 SELECT Pushdown • Presto における S3 SELECT Pushdown • Presto から S3 へのデータ参照に S3 SELECT を使⽤し、 Projection operation (e.g. SELECT)と Predicate operation (e.g. WHERE) を削減することで計算量を最適化 • ⾮圧縮, gzip, bzip2 の CSV ファイルをサポート [ { "classification": "presto-connector-hive", "properties": { "hive.s3select-pushdown.enabled": "true", "hive.s3select-pushdown.max-connections": "500" } }
  • 23.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. S3 SELECT Pushdown • 有効なシーン • データセットの半分以上をフィルタアウトするクエリ • Presto と Amazon S3 の間のネットワーク帯域が⼗分な環境 • Presto と S3 SELECT の両⽅でサポートしているデータタイプ をもつカラムを使う場合 • Timestamp, Real, Double は S3 SELECT Pushdown ⾮対応
  • 24.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto x AWS Glue
  • 25.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Glue Data Catalog との連携 • Presto Hive Connector にて Hive メタストアサービスに加えて Glue Data Catalog に対応 • メタストアを永続化したい場合 • 複数のクラスタ、サービス、アプリケーションなどでメタスト アを共有したい場合 [ { "Classification": "presto-connector-hive", "Properties": { "hive.metastore": "glue" } } ]
  • 26.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Glue Data Catalog との連携 • 制限事項あり • テーブル名のリネームには⾮対応 • Column statistics には⾮対応 • Hive Authorization には⾮対応 • https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-presto-glue.html#emr-presto- glue-knownissues
  • 27.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto x AWS Auto Scaling
  • 28.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Graceful Decommission • Auto Scaling のスケーリング操作時に猶予期間を設定 • Presto がデコミッション中のノードに新しいタスクをスケ ジューリングしないようにする • Presto が削除対象のノードで実⾏中のタスクを完了できるよう にする [ { "classification": "presto-config", "properties": { "graceful-shutdown-timeout": "1800s" } } ]
  • 29.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け
  • 30.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 31.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 32.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 33.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 34.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 35.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 36.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 37.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 38.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 39.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 40.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 41.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. Presto on AWS の使い分け Presto on EC2 Presto on EMR Athena Presto ソフトウェア PrestoSQL or PrestoDB PrestoSQL or PrestoDB PrestoDB のみ バージョン 任意 PrestoSQL 338 PrestoDB 0.232 PrestoDB 0.172 or 0.217 AWS マネジメントコンソー ルからのクエリ × × ※Step で代替可能 ◯ Presto UI / クエリプラン ◯ ◯ × クラスタプロビジョニング ⼿動 ⾃動 不要 クラスタ運⽤管理 必要 必要 不要 ノード数 任意 任意 設定不可 オートスケーリング △ ◯ - コスト EC2 利⽤料 EC2 利⽤料 EMR 利⽤料 Athena クエリ利⽤料 設定カスタマイズ ◯ ◯ × 主な利⽤シーン 任意のバージョンの組 み合わせが必要な場合 ノード数や設定などを⾃由に カスタマイズしたい場合 他の Hadoop/Spark アプリ ケーションと併⽤したい場合 サーバーレスでクエリしたい場合 ML Query, Partition Projection などの Athena 固有機能を使いた い場合
  • 42.
    © 2020, AmazonWeb Services, Inc. or its Affiliates. おわりに • AWS x Presto • EMR • S3 • Glue • Auto Scaling • Presto on AWS の使い分け AWS で Presto を徹底的に使いこなすワザを習得する • Presto 視点で AWS の各種サービスを使いこなす⽅法 • Presto on AWS を⽬的に合わせて使い分ける⽅法