© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Graph Database and Amazon Neptune
2018.11.01
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
自己紹介
五十嵐 建平
技術統括本部
ソリューションアーキテクト
好きなサービス
• Amazon Aurora
• Amazon RDS Performance Insights
• Amazon Neptune
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
内容についての注意点
• 本資料では2018年11月1日時点のサービス内容および価格についてご説明しています。最新の情報
は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.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
本セッションの内容
• どのような場面でグラフデータベースを使うべきか
• Amazon Neptuneの特徴
• Gremlinの例
• 開発時のベストプラクティス
• 可視化
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
どのような場面で
グラフデータベースを
使うべきなのか?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
グラフ構造〜ノードとエッジ
ソーシャルグラフ
出身地
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
自分が開発している
アプリケーションのデータは
グラフ構造なのか?
出身地
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
データモデリングからの視点
多対多
グラフデータベース
1対1
Key-Value ストア
多対1
RDBMS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
請求書では?
すべての関連が
多対1
It's Relational Data 請求書
マスタ
請求書
明細
顧客
https://images-fe.ssl-images-amazon.com/images/G/09/help/others/b2b_invoice_sample.png
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ソーシャルグラフでは?
すべての関連が多対多
It's Graph
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Many
Many-to-Many
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SQLからの視点
使用するSQL文に
再帰With句や
Connect By (Oracle)
を使う必要がある
with tab(ID,PID,Lv,Path) as(
select ID,PID,1
from Data
where PID is null
union all
select d.ID,d.PID,t.Lv+1
from tab t, Data d
where t.ID = d.PID)
select * from tab;
グラフ探索はクエリの複雑性が高くなりやすい
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
グラフデータのユースケース
ソーシャル
グラフ
ライフサイエンス ネットワーク/IT運用不正検出
レコメンデーション ナレッジグラフ
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
RDBによるグラフデータ(高度に連結したデータ)での課題
SQL
グラフ処理
に不向き
厳格なスキーマ
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
グラフデータベース
グラフ構造のために最適化された
効率的なストレージと
探索エンジン
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
グラフ処理の分類
Traversal Analytics
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Neptuneの特徴
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
従来のグラフデータベースの課題にアプローチ
可用性スケール I/F価格
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クエリ性能
• Traversalワークロードにおいて
毎秒100,000件のクエリをサポートするよう設計
• 最大15個のリードレプリカ
• 専用に設計されたクラウドネイティブなストレージサービス
• 最適化されたインメモリアーキテクチャ
• クエリの最適化
• 索引を作成する必要がない
• Neptune側で自動的に最適なI/Oパスを実行
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
リージョン
• 米国東部 (バージニア北部)
• 米国東部 (オハイオ)
• 米国西部 (オレゴン)
• 欧州 (アイルランド)
• 欧州 (ロンドン)
順次拡大予定
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Gremlinの例(基礎)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2つのグラフモデルとフレームワーク
Apache TinkerPop™ (OSS)
Gremlin Traversal Language
W3C標準
SPARQL Query Language
RDFプロパティグラフ
https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/access-graph-gremlin-differences.html
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
プロパティグラフ
• 頂点(Vertex)はエンティティ/ドメイン
• 辺(Edge)は頂点間の関係
name:
Bill
name:
Sarah
UserUser
FRIEND
strength: 1
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
プロパティグラフの作成
g.addV('User').property('name','Bill');
g.addV('User').property('name','Sarah');
g.V().has('name','Sarah').as('a').
V().has('name','Bill').
addE('FRIEND').to('a').property('strength',1);
g.V().has('name','Bill').out('FRIEND')
name:
Sarah
User
name:
Bill
User
2つの頂点を追加
FRIEND
strength: 1
エッジで接続
BillからFRIEND
をたどって
Sarahを得る
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Gremlin
• グラフ構造を渡り歩くための専用言語
• Domain-specific Language
• オブジェクトを探索する小人のイメージ
• 順序よくステップを踏んでいく
• エッジに行って…
ラベルやプロパティを見て…
必要であれば計算処理もして…
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
トラバーサルの例
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR WORKS_FOR
name:
Terry
WORKS_FOR
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
探索ソース
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR WORKS_FOR
name:
Terry
WORKS_FOR
g
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
探索の生成
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR WORKS_FOR
name:
Terry
WORKS_FOR
T
開始ノードを
探索
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IN側の WORKS_FOR エッジをフォロー
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR WORKS_FOR
name:
Terry
WORKS_FOR
TT
Incoming
エッジ
探索されるのは
頂点
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
さらにIN側のWORKS_FORエッジをフォロー
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR
name:
Terry
WORKS_FORWORKS_FOR
TT T
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ノードのカウント
g.V().has("name", "Sue").
in("WORKS_FOR").
in("WORKS_FOR").
count()
name:
Sue
name:
Ed
name:
Helen
WORKS_FOR WORKS_FOR
name:
Bill
name:
Mary
WORKS_FOR WORKS_FOR
name:
Terry
WORKS_FOR
3
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Gremlinの例
(Social Networkにおける
レコメンデーション)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
三角閉路を作る
FRIEND
太郎
花子
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
三角閉路を作る
FRIEND
FRIEND
雲海
太郎
花子
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
三角閉路を作る
FRIEND
FRIEND
雲海
太郎
花子
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
三角閉路を作る
FRIEND
FRIEND
雲海
太郎
花子
FRIEND
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
いいところ
• 似たもの同士を結びつける
• 類は友を呼ぶ
• 友だちの友だちは友だちだろう
• オンラインレコメンデーション
• "雲海"にバインド
• 周りのグラフから友だちではない"友だちの友だち"を探索
• 新たなエッジをレコメンデーション
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
新たなエッジをレコメンデーション
雲海
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
既に存在する友だち関係
FRIEND
雲海
太郎
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
見つけた!
FRIEND
FRIEND
雲海
太郎
花子
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
レコメンデーション
FRIEND
FRIEND
雲海
太郎
花子
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
サンプルデータ
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
新たな友だちをレコメンドする
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Terryを探す
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
ユーザ
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Terryの友だちを探索
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
ユーザ
友だち
方向は無視
探索集合をくくって
名前付け
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
友だちの友だち・・・
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
ユーザ
友だち
友だちの
友だち
FRIEND
FRIEND
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
…だけどTerryの友だちではない
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
ユーザ
友だち
友だちの
友だち
X
FRIEND
FRIEND
自分以外
名前付けされた
探索集合でもない
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
名前ごとにグループ化してカウント
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
nameごとに
グループ化して
カウントした値を
valuesに追加
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
共通の友だちの数でソート
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
結果
[Henry:3,
Emily:2,
Colin:2,
Kate:1,
Sarah:1,
Chloe:1]
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
クエリ性能
• Traversalワークロードにおいて
毎秒100,000件のクエリをサポートするよう設計
g.V().has('name','Terry').as('user').
both('FRIEND').aggregate('friends').
both('FRIEND').
where(neq('user')).where(without('friends')).
groupCount().by('name').
order(local).by(values, decr)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
開発時のベストプラクティス
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
RDBMSからの移行 (TinkerPop)
データベース S3バケット
バルクロードCSV作成/配置
SQL発行+整形を
EC2やコンテナで実施
フォルダ指定して
実行
スキーマ
ユーザ 商品
ノード
ユーザ-商品
エッジ
ユーザ-ユーザ
フォルダ
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EC2やLambdaからのアクセス
Neptune はVPC内に配置される
• Public IP は付与されない
• Lambdaを使うならVPC内に
https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/access-graph-launch-ec2-instance.html
VPC
インターネットEC2
Lambda
S3バケット
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
バルクロード
• トランザクションとはならない
• 追加のみ
• 1ファイルずつマルチスレッド実行される
 大きなgzip圧縮されたファイルを用いるのが良い
• インスタンスタイプによりほぼ線形に速度が変わる
 バルクロード時だけ r4.8xlarge を使用して終わったら
通常クエリ用のインスタンスタイプにする
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SQL文の移行
• SQLの実行計画をヒントにトラバーサルを組み立てる
PK検索
 NESTED LOOPS
 FILTER
 NESTED LOOPS
g.V().has(…).
both(…).
where(…).
both(…)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
デバッグ
path(), simplePath(),
cyclicPath() を使ってトラバー
サルを把握する
gremlin> g.V(1).both().both()
==>v[1]
==>v[4]
==>v[6]
==>v[1]
==>v[5]
==>v[3]
==>v[1]
gremlin> g.V(1).both().both().simplePath()
==>v[4]
==>v[6]
==>v[5]
==>v[3]
gremlin> g.V(1).both().both().simplePath().path()
==>[v[1], v[3], v[4]]
==>[v[1], v[3], v[6]]
==>[v[1], v[4], v[5]]
==>[v[1], v[4], v[3]]
gremlin> g.V(1).both().both().cyclicPath()
==>v[1]
==>v[1]
==>v[1]
gremlin> g.V(1).both().both().cyclicPath().path()
==>[v[1], v[3], v[1]]
==>[v[1], v[2], v[1]]
==>[v[1], v[4], v[1]]
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
インターフェイス一覧
Tinkerpop/Gremlin RDF/SPARQL バルクロード Neptuneの管理
コンソール Gremlin Console RDF4J Console
RDF4J Workbench
- AWS CLI
Java Gremlin Driver RDF4J - AWS SDK for Java
Python Gremlin-Python Driver - - boto3
.NET Gremlin.NET - - AWS SDK for .NET
HTTP REST HTTP REST (Gremlin) HTTP REST (SPARQL) Neptune Loader API Health Status
REST以外の
HTTP
Gremlin HTTP
WebSocket API
SPARQL HTTP - -
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
返り値はjson
pythonの例
graph = Graph()
g = graph.traversal().withRemote(
DriverRemoteConnection(
'ws://your-neptune-endpoint:8182/gremlin','g'))
print(g.V().limit(2).toList())
WebSocket APIの結果
がパススルーされる
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
更新処理
• 1リクエスト = 1トランザクションとなる (READ COMMITTED)
• よくある悩み: 大量一括更新
スループットを最適化するためには・・・
• アプリ側で並列化  並列度 = 2 x vCPU数からスタートして調整
• ただし並列化するとトランザクションも分割される
• 並列化時の更新競合が発生しないようにする
• 粒度を大きくする  1リクエストの最大サイズは150MB
• deleteはリクエストサイズが小さい
• r4.8xlarge で数億件一括削除も可能
• スループットを上げるのなら並列化する
• ロングラン時には neptune_query_timeout を調整する
• デフォルト2分
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
インメモリ最適化
• Neptuneはインメモリ処理に最適化している
• ホットデータがインスタンスにキャッシュされておくようにする
• メモリ量はインスタンスタイプに依存する
• リードレプリカを活用する
• 更新と読み取りの分離
• アプリケーション側でグラフ領域によってエンドポイントを変える
• 定常時にストレージ読み込みがないことが望ましい
• CloudWatchメトリックの ReadThroughput が低いことを確認する
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
マルチテナンシー
• Gremlin
• 単一グラフのみをサポート
• 複数グラフを扱う際はアプリケーション側でカバーすればOK
• ラベルやプロパティを重複しないようにすれば良い
• SPARQL
• 名前付きグラフをサポート
• データローダーは NQuads またはトリプルでの名前付きグラフ
指定をサポート
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
可視化
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
何のための可視化か?
全体を見るための
可視化
一部を見るための
可視化
大規模グラフのOLTP用途では
こちらが中心となる
視覚的に全体的な構造を把握
クラスタリングの仮説を立てる
ドリルダウン
視覚的にターゲット周辺の構造を把握
トラバーサルの仮説を立てる
大規模グラフではすべてのデータを
描画しても情報過多となる
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
オープンなインターフェイスの活用
GremlinまたはRDF/SPARQLに対応した可視化ツールを使用
※ Neptune自体は可視化機能を提供しない
可視化ツールの例 カテゴリ インターフェイス
Graphexp オープンソース Gremlin
Tom Sawyer Software 商用 Gremlin
RDF/SPARQL
Metaphactory 商用 Gremlin
RDF/SPARQL
Cambridge Intelligence / Keylines 商用 RDF/SPARQL
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Graphexp
JavaScriptベースのシンプルな
可視化ツール
簡単な設定でNeptuneに対応
Webブラウザから直接Neptune
エンドポイントにアクセス
できる必要がある
https://github.com/bricaud/graphexp
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
可視化の使用例
クエリのデバッグの補助
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
まとめ
• どのような場面でグラフデータベースを使うべきか
• Amazon Neptuneの特徴
• Gremlinの例
• 開発時のベストプラクティス
• 可視化
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
さいごに
Amazon Neptune についてもっと知りたい方はこちら
• 公式ページ
https://aws.amazon.com/jp/neptune/
• ドキュメントやチュートリアルなどのリソース
https://aws.amazon.com/jp/neptune/developer-resources/
• Amazon Neptune Forum
https://forums.aws.amazon.com/forum.jspa?forumID=253
• [AWS Black Belt Online Seminar] Amazon Neptune
https://aws.amazon.com/jp/blogs/news/webinar-bb-neptune-20180703/
Amazon Neptune で
スケーラブルで堅牢なグラフデータベースを
実現しましょう!
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ご参加ありがとうございました

More Related Content

PDF
20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL
PDF
The Twelve-Factor Appで考えるAWSのサービス開発
PDF
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
PDF
20190911 AWS Black Belt Online Seminar AWS Batch
PDF
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
PDF
20210316 AWS Black Belt Online Seminar AWS DataSync
PPTX
20211109 JAWS-UG SRE keynotes
PDF
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...
20190424 AWS Black Belt Online Seminar Amazon Aurora MySQL
The Twelve-Factor Appで考えるAWSのサービス開発
20200722 AWS Black Belt Online Seminar AWSアカウント シングルサインオンの設計と運用
20190911 AWS Black Belt Online Seminar AWS Batch
AWS Black Belt Online Seminar 2018 Amazon DynamoDB Advanced Design Pattern
20210316 AWS Black Belt Online Seminar AWS DataSync
20211109 JAWS-UG SRE keynotes
20180425 AWS Black Belt Online Seminar Amazon Relational Database Service (Am...

What's hot (20)

PDF
20200811 AWS Black Belt Online Seminar CloudEndure
PDF
20190806 AWS Black Belt Online Seminar AWS Glue
PDF
20190828 AWS Black Belt Online Seminar Amazon Aurora with PostgreSQL Compatib...
PDF
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
PDF
オンプレミスRDBMSをAWSへ移行する手法
PDF
[Aurora事例祭り]Amazon Aurora を使いこなすためのベストプラクティス
PDF
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
PDF
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
PDF
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
PDF
AWS Black Belt Online Seminar 2017 AWSにおけるアプリ認証パターンのご紹介
PDF
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
PDF
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
PDF
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
PDF
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
PDF
AWS Black Belt Online Seminar 2017 Amazon ElastiCache
PDF
20190320 AWS Black Belt Online Seminar Amazon EBS
PDF
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
PDF
AWSのログ管理ベストプラクティス
PDF
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
PDF
AWS Black Belt Online Seminar コストの観点から見るアカウント管理
20200811 AWS Black Belt Online Seminar CloudEndure
20190806 AWS Black Belt Online Seminar AWS Glue
20190828 AWS Black Belt Online Seminar Amazon Aurora with PostgreSQL Compatib...
20190731 Black Belt Online Seminar Amazon ECS Deep Dive
オンプレミスRDBMSをAWSへ移行する手法
[Aurora事例祭り]Amazon Aurora を使いこなすためのベストプラクティス
20191029 AWS Black Belt Online Seminar Elastic Load Balancing (ELB)
20190129 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
202110 AWS Black Belt Online Seminar AWS Site-to-Site VPN
AWS Black Belt Online Seminar 2017 AWSにおけるアプリ認証パターンのご紹介
20190130 AWS Black Belt Online Seminar AWS Identity and Access Management (AW...
AWS Black Belt Online Seminar 2017 Amazon DynamoDB
20190220 AWS Black Belt Online Seminar Amazon S3 / Glacier
202205 AWS Black Belt Online Seminar Amazon VPC IP Address Manager (IPAM)
AWS Black Belt Online Seminar 2017 Amazon ElastiCache
20190320 AWS Black Belt Online Seminar Amazon EBS
20190319 AWS Black Belt Online Seminar Amazon FSx for Windows Server
AWSのログ管理ベストプラクティス
AWS BlackBelt Online Seminar 2017 Amazon CloudFront + AWS Lambda@Edge
AWS Black Belt Online Seminar コストの観点から見るアカウント管理
Ad

Similar to Graph Database and Amazon Neptune (20)

PDF
20180703 AWS Black Belt Online Seminar Amazon Neptune
PDF
AWSの様々なアーキテクチャ
PDF
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
PPT
Blueprintsについて
PDF
Re invent 2017 データベースサービス総復習!
PDF
大規模ネットワークの性質と先端グラフアルゴリズム
PDF
AWSによるグラフDB構築
PDF
Lunch & Learn, AWS NoSQL Services
PDF
セマンテックウェブとRDFDB
PDF
社会ネットワーク分析第7回
PPTX
Neoの世界へ
PPTX
Getting Started with Graph Database with Python
PDF
AWSクラウドサービスツアー
PDF
レコメンデーション(協調フィルタリング)の基礎
PDF
RDBでのツリー表現入門2024
PDF
RDBでのツリー表現入門
PDF
Apache tinkerpopとグラフデータベースの世界
PDF
「NOSQLの基礎知識」講義資料 第20回JDMC定例セミナー(201310)
KEY
activerecord-turntable
PPTX
Game Architecture Trends in Tokyo Kansai Social Game Study#5
20180703 AWS Black Belt Online Seminar Amazon Neptune
AWSの様々なアーキテクチャ
20180619 AWS Black Belt Online Seminar データレイク入門: AWSで様々な規模のデータレイクを分析する効率的な方法
Blueprintsについて
Re invent 2017 データベースサービス総復習!
大規模ネットワークの性質と先端グラフアルゴリズム
AWSによるグラフDB構築
Lunch & Learn, AWS NoSQL Services
セマンテックウェブとRDFDB
社会ネットワーク分析第7回
Neoの世界へ
Getting Started with Graph Database with Python
AWSクラウドサービスツアー
レコメンデーション(協調フィルタリング)の基礎
RDBでのツリー表現入門2024
RDBでのツリー表現入門
Apache tinkerpopとグラフデータベースの世界
「NOSQLの基礎知識」講義資料 第20回JDMC定例セミナー(201310)
activerecord-turntable
Game Architecture Trends in Tokyo Kansai Social Game Study#5
Ad

More from Amazon Web Services Japan (20)

PDF
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
PDF
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
PDF
Infrastructure as Code (IaC) 談義 2022
PDF
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
PDF
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
PDF
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
PPTX
20220409 AWS BLEA 開発にあたって検討したこと
PDF
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
PDF
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
PDF
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
PDF
Amazon QuickSight の組み込み方法をちょっぴりDD
PDF
マルチテナント化で知っておきたいデータベースのこと
PDF
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
PDF
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
PDF
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
PDF
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
PDF
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
PPTX
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
PDF
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
PDF
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202205 AWS Black Belt Online Seminar Amazon FSx for OpenZFS
202204 AWS Black Belt Online Seminar AWS IoT Device Defender
Infrastructure as Code (IaC) 談義 2022
202204 AWS Black Belt Online Seminar Amazon Connect を活用したオンコール対応の実現
202204 AWS Black Belt Online Seminar Amazon Connect Salesforce連携(第1回 CTI Adap...
Amazon Game Tech Night #25 ゲーム業界向け機械学習最新状況アップデート
20220409 AWS BLEA 開発にあたって検討したこと
202202 AWS Black Belt Online Seminar AWS Managed Rules for AWS WAF の活用
202203 AWS Black Belt Online Seminar Amazon Connect Tasks.pdf
SaaS テナント毎のコストを把握するための「AWS Application Cost Profiler」のご紹介
Amazon QuickSight の組み込み方法をちょっぴりDD
マルチテナント化で知っておきたいデータベースのこと
機密データとSaaSは共存しうるのか!?セキュリティー重視のユーザー層を取り込む為のネットワーク通信のアプローチ
パッケージソフトウェアを簡単にSaaS化!?既存の資産を使ったSaaS化手法のご紹介
202202 AWS Black Belt Online Seminar Amazon Connect Customer Profiles
Amazon Game Tech Night #24 KPIダッシュボードを最速で用意するために
202202 AWS Black Belt Online Seminar AWS SaaS Boost で始めるSaaS開発⼊⾨
[20220126] JAWS-UG 2022初頭までに葬ったAWSアンチパターン大紹介
202111 AWS Black Belt Online Seminar AWSで構築するSmart Mirrorのご紹介
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...

Recently uploaded (7)

PDF
ココロ分解帳|感情をやさしく分解し自分と他者を理解するためのモバイルノートアプリ
PDF
Working as an OSS Developer at Ruby Association Activity Report 2025
PDF
翔泳社 「C++ ゼロからはじめるプログラミング」対応 C++学習教材(三谷純)
PPTX
生成AIとモデルベース開発:実はとても相性が良いことを説明します。まあそうだろうなと思われる方はご覧ください。
PDF
AIシステムのセキュリティ:脅威となりつつあるAIの現状と課題 [English] Security of AI Systems: The Current...
PDF
20250826_Devinで切り拓く沖縄ITの未来_AI駆動開発勉強会 沖縄支部 第2回
ココロ分解帳|感情をやさしく分解し自分と他者を理解するためのモバイルノートアプリ
Working as an OSS Developer at Ruby Association Activity Report 2025
翔泳社 「C++ ゼロからはじめるプログラミング」対応 C++学習教材(三谷純)
生成AIとモデルベース開発:実はとても相性が良いことを説明します。まあそうだろうなと思われる方はご覧ください。
AIシステムのセキュリティ:脅威となりつつあるAIの現状と課題 [English] Security of AI Systems: The Current...
20250826_Devinで切り拓く沖縄ITの未来_AI駆動開発勉強会 沖縄支部 第2回

Graph Database and Amazon Neptune

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Graph Database and Amazon Neptune 2018.11.01
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 自己紹介 五十嵐 建平 技術統括本部 ソリューションアーキテクト 好きなサービス • Amazon Aurora • Amazon RDS Performance Insights • Amazon Neptune
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 内容についての注意点 • 本資料では2018年11月1日時点のサービス内容および価格についてご説明しています。最新の情報 は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.
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 本セッションの内容 • どのような場面でグラフデータベースを使うべきか • Amazon Neptuneの特徴 • Gremlinの例 • 開発時のベストプラクティス • 可視化
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. どのような場面で グラフデータベースを 使うべきなのか?
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. グラフ構造〜ノードとエッジ ソーシャルグラフ 出身地
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 自分が開発している アプリケーションのデータは グラフ構造なのか? 出身地
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. データモデリングからの視点 多対多 グラフデータベース 1対1 Key-Value ストア 多対1 RDBMS
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 請求書では? すべての関連が 多対1 It's Relational Data 請求書 マスタ 請求書 明細 顧客 https://images-fe.ssl-images-amazon.com/images/G/09/help/others/b2b_invoice_sample.png
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ソーシャルグラフでは? すべての関連が多対多 It's Graph
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Many Many-to-Many
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SQLからの視点 使用するSQL文に 再帰With句や Connect By (Oracle) を使う必要がある with tab(ID,PID,Lv,Path) as( select ID,PID,1 from Data where PID is null union all select d.ID,d.PID,t.Lv+1 from tab t, Data d where t.ID = d.PID) select * from tab; グラフ探索はクエリの複雑性が高くなりやすい
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. グラフデータのユースケース ソーシャル グラフ ライフサイエンス ネットワーク/IT運用不正検出 レコメンデーション ナレッジグラフ
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. RDBによるグラフデータ(高度に連結したデータ)での課題 SQL グラフ処理 に不向き 厳格なスキーマ
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. グラフデータベース グラフ構造のために最適化された 効率的なストレージと 探索エンジン
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. グラフ処理の分類 Traversal Analytics
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Neptuneの特徴
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 従来のグラフデータベースの課題にアプローチ 可用性スケール I/F価格
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クエリ性能 • Traversalワークロードにおいて 毎秒100,000件のクエリをサポートするよう設計 • 最大15個のリードレプリカ • 専用に設計されたクラウドネイティブなストレージサービス • 最適化されたインメモリアーキテクチャ • クエリの最適化 • 索引を作成する必要がない • Neptune側で自動的に最適なI/Oパスを実行
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. リージョン • 米国東部 (バージニア北部) • 米国東部 (オハイオ) • 米国西部 (オレゴン) • 欧州 (アイルランド) • 欧州 (ロンドン) 順次拡大予定
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Gremlinの例(基礎)
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2つのグラフモデルとフレームワーク Apache TinkerPop™ (OSS) Gremlin Traversal Language W3C標準 SPARQL Query Language RDFプロパティグラフ https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/access-graph-gremlin-differences.html
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. プロパティグラフ • 頂点(Vertex)はエンティティ/ドメイン • 辺(Edge)は頂点間の関係 name: Bill name: Sarah UserUser FRIEND strength: 1
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. プロパティグラフの作成 g.addV('User').property('name','Bill'); g.addV('User').property('name','Sarah'); g.V().has('name','Sarah').as('a'). V().has('name','Bill'). addE('FRIEND').to('a').property('strength',1); g.V().has('name','Bill').out('FRIEND') name: Sarah User name: Bill User 2つの頂点を追加 FRIEND strength: 1 エッジで接続 BillからFRIEND をたどって Sarahを得る
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Gremlin • グラフ構造を渡り歩くための専用言語 • Domain-specific Language • オブジェクトを探索する小人のイメージ • 順序よくステップを踏んでいく • エッジに行って… ラベルやプロパティを見て… 必要であれば計算処理もして…
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. トラバーサルの例 g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR WORKS_FOR name: Terry WORKS_FOR
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 探索ソース g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR WORKS_FOR name: Terry WORKS_FOR g
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 探索の生成 g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR WORKS_FOR name: Terry WORKS_FOR T 開始ノードを 探索
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. IN側の WORKS_FOR エッジをフォロー g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR WORKS_FOR name: Terry WORKS_FOR TT Incoming エッジ 探索されるのは 頂点
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. さらにIN側のWORKS_FORエッジをフォロー g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR name: Terry WORKS_FORWORKS_FOR TT T
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ノードのカウント g.V().has("name", "Sue"). in("WORKS_FOR"). in("WORKS_FOR"). count() name: Sue name: Ed name: Helen WORKS_FOR WORKS_FOR name: Bill name: Mary WORKS_FOR WORKS_FOR name: Terry WORKS_FOR 3
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Gremlinの例 (Social Networkにおける レコメンデーション)
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 三角閉路を作る FRIEND 太郎 花子
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 三角閉路を作る FRIEND FRIEND 雲海 太郎 花子
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 三角閉路を作る FRIEND FRIEND 雲海 太郎 花子
  • 36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 三角閉路を作る FRIEND FRIEND 雲海 太郎 花子 FRIEND
  • 37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. いいところ • 似たもの同士を結びつける • 類は友を呼ぶ • 友だちの友だちは友だちだろう • オンラインレコメンデーション • "雲海"にバインド • 周りのグラフから友だちではない"友だちの友だち"を探索 • 新たなエッジをレコメンデーション
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 新たなエッジをレコメンデーション 雲海
  • 39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 既に存在する友だち関係 FRIEND 雲海 太郎
  • 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 見つけた! FRIEND FRIEND 雲海 太郎 花子
  • 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. レコメンデーション FRIEND FRIEND 雲海 太郎 花子
  • 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. サンプルデータ
  • 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 新たな友だちをレコメンドする g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr)
  • 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Terryを探す g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr) ユーザ
  • 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Terryの友だちを探索 g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr) ユーザ 友だち 方向は無視 探索集合をくくって 名前付け
  • 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 友だちの友だち・・・ g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr) ユーザ 友だち 友だちの 友だち FRIEND FRIEND
  • 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. …だけどTerryの友だちではない g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr) ユーザ 友だち 友だちの 友だち X FRIEND FRIEND 自分以外 名前付けされた 探索集合でもない
  • 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 名前ごとにグループ化してカウント g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr) nameごとに グループ化して カウントした値を valuesに追加
  • 49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 共通の友だちの数でソート g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr)
  • 50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 結果 [Henry:3, Emily:2, Colin:2, Kate:1, Sarah:1, Chloe:1]
  • 51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. クエリ性能 • Traversalワークロードにおいて 毎秒100,000件のクエリをサポートするよう設計 g.V().has('name','Terry').as('user'). both('FRIEND').aggregate('friends'). both('FRIEND'). where(neq('user')).where(without('friends')). groupCount().by('name'). order(local).by(values, decr)
  • 52. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 開発時のベストプラクティス
  • 53. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. RDBMSからの移行 (TinkerPop) データベース S3バケット バルクロードCSV作成/配置 SQL発行+整形を EC2やコンテナで実施 フォルダ指定して 実行 スキーマ ユーザ 商品 ノード ユーザ-商品 エッジ ユーザ-ユーザ フォルダ
  • 54. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EC2やLambdaからのアクセス Neptune はVPC内に配置される • Public IP は付与されない • Lambdaを使うならVPC内に https://docs.aws.amazon.com/ja_jp/neptune/latest/userguide/access-graph-launch-ec2-instance.html VPC インターネットEC2 Lambda S3バケット
  • 55. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. バルクロード • トランザクションとはならない • 追加のみ • 1ファイルずつマルチスレッド実行される  大きなgzip圧縮されたファイルを用いるのが良い • インスタンスタイプによりほぼ線形に速度が変わる  バルクロード時だけ r4.8xlarge を使用して終わったら 通常クエリ用のインスタンスタイプにする
  • 56. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SQL文の移行 • SQLの実行計画をヒントにトラバーサルを組み立てる PK検索  NESTED LOOPS  FILTER  NESTED LOOPS g.V().has(…). both(…). where(…). both(…)
  • 57. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. デバッグ path(), simplePath(), cyclicPath() を使ってトラバー サルを把握する gremlin> g.V(1).both().both() ==>v[1] ==>v[4] ==>v[6] ==>v[1] ==>v[5] ==>v[3] ==>v[1] gremlin> g.V(1).both().both().simplePath() ==>v[4] ==>v[6] ==>v[5] ==>v[3] gremlin> g.V(1).both().both().simplePath().path() ==>[v[1], v[3], v[4]] ==>[v[1], v[3], v[6]] ==>[v[1], v[4], v[5]] ==>[v[1], v[4], v[3]] gremlin> g.V(1).both().both().cyclicPath() ==>v[1] ==>v[1] ==>v[1] gremlin> g.V(1).both().both().cyclicPath().path() ==>[v[1], v[3], v[1]] ==>[v[1], v[2], v[1]] ==>[v[1], v[4], v[1]]
  • 58. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. インターフェイス一覧 Tinkerpop/Gremlin RDF/SPARQL バルクロード Neptuneの管理 コンソール Gremlin Console RDF4J Console RDF4J Workbench - AWS CLI Java Gremlin Driver RDF4J - AWS SDK for Java Python Gremlin-Python Driver - - boto3 .NET Gremlin.NET - - AWS SDK for .NET HTTP REST HTTP REST (Gremlin) HTTP REST (SPARQL) Neptune Loader API Health Status REST以外の HTTP Gremlin HTTP WebSocket API SPARQL HTTP - -
  • 59. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 返り値はjson pythonの例 graph = Graph() g = graph.traversal().withRemote( DriverRemoteConnection( 'ws://your-neptune-endpoint:8182/gremlin','g')) print(g.V().limit(2).toList()) WebSocket APIの結果 がパススルーされる
  • 60. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 更新処理 • 1リクエスト = 1トランザクションとなる (READ COMMITTED) • よくある悩み: 大量一括更新 スループットを最適化するためには・・・ • アプリ側で並列化  並列度 = 2 x vCPU数からスタートして調整 • ただし並列化するとトランザクションも分割される • 並列化時の更新競合が発生しないようにする • 粒度を大きくする  1リクエストの最大サイズは150MB • deleteはリクエストサイズが小さい • r4.8xlarge で数億件一括削除も可能 • スループットを上げるのなら並列化する • ロングラン時には neptune_query_timeout を調整する • デフォルト2分
  • 61. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. インメモリ最適化 • Neptuneはインメモリ処理に最適化している • ホットデータがインスタンスにキャッシュされておくようにする • メモリ量はインスタンスタイプに依存する • リードレプリカを活用する • 更新と読み取りの分離 • アプリケーション側でグラフ領域によってエンドポイントを変える • 定常時にストレージ読み込みがないことが望ましい • CloudWatchメトリックの ReadThroughput が低いことを確認する
  • 62. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. マルチテナンシー • Gremlin • 単一グラフのみをサポート • 複数グラフを扱う際はアプリケーション側でカバーすればOK • ラベルやプロパティを重複しないようにすれば良い • SPARQL • 名前付きグラフをサポート • データローダーは NQuads またはトリプルでの名前付きグラフ 指定をサポート
  • 63. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 可視化
  • 64. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 何のための可視化か? 全体を見るための 可視化 一部を見るための 可視化 大規模グラフのOLTP用途では こちらが中心となる 視覚的に全体的な構造を把握 クラスタリングの仮説を立てる ドリルダウン 視覚的にターゲット周辺の構造を把握 トラバーサルの仮説を立てる 大規模グラフではすべてのデータを 描画しても情報過多となる
  • 65. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. オープンなインターフェイスの活用 GremlinまたはRDF/SPARQLに対応した可視化ツールを使用 ※ Neptune自体は可視化機能を提供しない 可視化ツールの例 カテゴリ インターフェイス Graphexp オープンソース Gremlin Tom Sawyer Software 商用 Gremlin RDF/SPARQL Metaphactory 商用 Gremlin RDF/SPARQL Cambridge Intelligence / Keylines 商用 RDF/SPARQL
  • 66. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Graphexp JavaScriptベースのシンプルな 可視化ツール 簡単な設定でNeptuneに対応 Webブラウザから直接Neptune エンドポイントにアクセス できる必要がある https://github.com/bricaud/graphexp
  • 67. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 可視化の使用例 クエリのデバッグの補助
  • 68. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. まとめ • どのような場面でグラフデータベースを使うべきか • Amazon Neptuneの特徴 • Gremlinの例 • 開発時のベストプラクティス • 可視化
  • 69. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. さいごに Amazon Neptune についてもっと知りたい方はこちら • 公式ページ https://aws.amazon.com/jp/neptune/ • ドキュメントやチュートリアルなどのリソース https://aws.amazon.com/jp/neptune/developer-resources/ • Amazon Neptune Forum https://forums.aws.amazon.com/forum.jspa?forumID=253 • [AWS Black Belt Online Seminar] Amazon Neptune https://aws.amazon.com/jp/blogs/news/webinar-bb-neptune-20180703/ Amazon Neptune で スケーラブルで堅牢なグラフデータベースを 実現しましょう!
  • 70. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ご参加ありがとうございました