Skip to main content
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Lunch & Learn,
AWS NoSQL Services
アマゾン ウェブ サービス ジャパン株式会社
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
⾃⼰紹介
• 成田 俊 id:oranie
• 経歴
–前職のWeb系会社でインフラエンジニアを担当、主にMySQLや
Cassandraの運用などに携わる
–Cassandra summit JPN 2014, 2017 スピーカー登壇
• AWSJでの担当
–NoSQLサービス、DynamoDBをメインに技術支援を担当
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
最新のアプリケーションで求められる新しい要件
ユーザー: 100万以上
データ量: TB–PB–EB
場所: グローバル
パフォーマンス: ミリ秒–マイクロ秒
リクエスト: 数百万
アクセス: ウェブ/モバイル/IoT/デバイス
拡張: スケールアップ/ダウン、スケ
ールアウト/イン
⽀払い: 従量課⾦
開発者アクセス: APIアクセス
Social mediaRide hailing Media streaming Dating
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
⼀般的なデータカテゴリとユースケース
Relational
参照整合性、
ACIDトランザク
ション、
schema-
on-write
リフト&シフト、
ERP、CRM、⾦融
Key-value
⾼スループッ
ト、低レイテ
ンシーの読み
込みと書き込
み、無限のス
ケール
リアルタイム⼊
札、ショッピン
グカート、ソー
シャル、製品カ
タログ、顧客の
好み
Document
ドキュメント
を保存し、任
意の属性にク
エリーですば
やくアクセス
コンテンツ管理、
パーソナライ
ゼーション、モ
バイル
In-memory
マイクロ秒の
レイテンシー
でキーによる
クエリー
リーダーボード、
リアルタイム分析、
キャッシュ
Graph
すばやく簡単
にデータ間の
関係作成しナ
ビゲート
不正検知、ソー
シャルネットワー
キング、レコメン
デーションエンジ
ン
Time-series
データを時系
列に収集、格
納、処理
IoTアプリケー
ション、イベント
トラッキング
Ledger
アプリケーショ
ンデータへのす
べての変更に対
する完全で不変
で検証可能な履
歴
SoR(Systems
of record)、サプラ
イチェーン、ヘル
スケア、届出、財
務
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Purpose-Builtデータベース
Relational Key-value Document In-memory Graph Time-series Ledger
DynamoDB NeptuneAmazon RDS
Aurora CommercialCommunity
Timestream QLDBElastiCacheDocumentDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon Aurora
クラウドのために構築されたMySQL、PostgreSQL互換のリレーショナルデータベース
商⽤データベースのパフォーマンスと可⽤性を1/10のコストで実現
パフォーマンスと
スケーラビリティ
可⽤性と耐久性 ⾼い安全性 完全な管理
標準的なMySQLの5倍、PostgreSQL
の3倍のスループット; 最⼤15の
リードレプリカによるスケールア
ウト
耐障害性、⾃⼰修復ストレージ、
3つのアベイラビリティゾーンに
またがる6つのデータコピー;
Amazon S3への継続的なバック
アップ
ネットワークの隔離、保
存データ、転送データの
暗号化
RDSによる管理:
ハードウェアプロビジョニング、
ソフトウェアパッチ、セットアッ
プ、設定、バックアップなし
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon Relational Database Service (RDS)
⼈気のある6つのデータベースエンジンの選択による管理されたリレーショナルデー
タベースサービス
容易な管理 可⽤性と耐久性 ⾼い拡張性 ⾼速で安全
インフラストラクチャのプロ
ビジョニング、データベース
のインストール、メンテナン
スは不要
マルチAZデータレプリケー
ション、⾃動バックアップ、
スナップショット、⾃動フェ
イルオーバー
数クリックでデータベー
スのコンピュートとスト
レージを拡張可能;
アプリケーションのダウ
ンタイムは最⼩限
SSDストレージと保証された
プロビジョンドI/O; 保存時、
転送中のデータ暗号化
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DynamoDB
あらゆる規模に対応する⾼速で柔軟なキーバリューデータベースサービス
⾼いセキュリティ
デフォルトですべてのデータ
を暗号化; 堅牢なセキュリ
ティのためAWS IAMと完全に
統合
スケールに応じた
パフォーマンス
規模に関係なく、⼀貫して数
ミリ秒台の応答時間を実現; 事
実上無制限のスループットで
アプリケーションを構築可能
グルーバルなユーザー、
アプリのためのグローバ
ルなデータベース
複数のAWSリージョンにまたが
りテーブルを簡単に複製するこ
とで、ローカルデータにすばや
くアクセスできるグローバルア
プリケーションを構築
サーバーレス
サーバーのプロビジョニング、
ソフトウェアのパッチ適⽤、
アップグレードは不要; ⾃動ス
ケールアップ/ダウン; データの
継続的なバックアップ
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB
⾼速、スケーラブル、⾼可⽤かつフルマネージド型MongoDB互換のデータ
ベースサービス
フルマネージド型
AWSによる管理: ハードウェ
アプロビジョニング、ソフ
トウェアパッチ、セット
アップ、設定、バックアッ
プは不要
⾼速
毎秒数百万のリクエスト、
ミリ秒のレイテンシー
MongoDBとの互換性
MongoDB Community Edition 3.6と
の互換性; 同⼀のドライバー、
ツールが利⽤可能
信頼性
フルバックアップと復元を⾏う
3つのAZにまたがる6つのデー
タのレプリカ
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon ElastiCache
Redis、Memcached互換のインメモリーデータストア、キャッシュ
安全性と信頼性
ネットワーク分離、データ
の保管、通信時の暗号化、
HIPAA、PCI、FedRAMP準拠、
マルチAZ、⾃動フェイル
オーバー
Redis & Memcached互換
オープンソースRedis、
Memcachedとの完全な互換性
容易なスケール
シャーディングとレプリカ
を使⽤し書き込みと読み込
みをスケール
⾮常に⾼い
パフォーマンス
インメモリーデータストア、
インメモリーキャッシュ機能、
マイクロ秒単位の応答時間
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon Neptune
フルマネージド型グラフデータベース
容易
Gremlin、SPARQLを使⽤して、
簡単にパワフルなクエリー
を構築
⾼速
数⼗億の関係をミリ秒で
クエリー
オープン
Apache TinkerPop & W3C RDF graph
モデルをサポート
信頼性
フルバックアップと復元を⾏う
3つのAZにまたがる6つのデー
タのレプリカ
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon Quantum Ledger Database (QLDB)
フルマネージド型台帳データベース (2019/9/10 GA Launch)
アプリケーションデータに加えられたすべての変更の履歴を追跡して確認
不変
データに対する⼀連のすべての変
更レコードを維持します。これは
削除、変更することはできなため、
完全な履歴への問い合わせ、分析
することが可能
暗号的に検証可能
データの履歴を安全な出
⼒するため暗号化を使
使いやすさ
使いやすく、SQL APIなどの
使い慣れたデータベースの
機能を使⽤してデータを参
照可能
⾼い拡張性
⼀般的なブロックチェーン
フレームワークよりも2〜3
倍のトランザクションを実
⾏
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon Timestream (sign up for the preview)
⾼速でスケーラブル、フルマネージド型時系列データベース
リレーショナルデータベースの
1/10のコストで1,000倍⾼速
1秒あたり数百万回という
インサートレートでデータ
収集
数兆に及び⽇々の
イベント
適応型クエリー処理エンジ
ンは安定した予測可能なパ
フォーマンスを維持
時系列分析
補完、スムージング、近似
のためのビルトイン関数
サーバーレス
セットアップ、設定、サーバー
プロビジョニング、ソフトウェ
アのパッチの⾃動化
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Database Migration Service (AWS DMS)
M I G R A T I N G
D A T A B A S E S
T O A W S
オンプレミス、AWS間での移⾏
データベース間の移⾏
⾃動でスキーマの変換
ゼロダウンタイム移⾏のためのデータ
レプリケーション
100,000+
databases migrated
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DynamoDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DynamoDB
Fully managed nonrelational database for any scale
高速で一貫した性能
事実上無制限のスループット
ストレージ容量も制限なし
通信と保存データの暗号化
柔軟な権限管理
PCI, HIPAA, FIPS140-2など認証
SLAの提供
メンテナンスフリー
サーバレス
Auto scaling
バックアップ/リストア
Global tables
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Table構造
Table
Items
Attributes
Partition
Key
Sort
Key
必須
Key-value access pattern
データの分布を決定
オプション
Model 1:N relationships
Queryによる幅広い探索で利用
All items for key
==, <, >, >=, <=
“begins with”
“between”
“contains”
“in”
sorted results
counts
top/bottom N values
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Item操作について
• 読み込み
• GetItem
• TransactGetItems
• BatchGet
• Query
• Scan
• 書き込み
• PutItem
• Update
• TransactWriteItems
• BatchWriteItem
• Delete
• Get/Put/Update/Deleteは
Partition key とSort keyを指定
して対象Itemを決定
• QueryはPartition keyのみ指定
し、Sort Keyは条件指定による
範囲探索も可能
• 書き込みは条件付き書き込み
設定も可能
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
DynamoDB Transactions
DynamoDBで複数Item、複数tableに対する書き込
み操作や読み込み操作でACIDトランザクションが
可能に
トランザクション分離レベルはserializableでロッ
クは取らない
トランザクションの進⾏中にアイテムがトランザ
クション外で変更された場合、トランザクション
はキャンセルされ、例外を発⽣させたItemまたは
Itemに関する詳細がスローされる
GlobalTableではデフォルト無効、有効にした場合
もトランザクションはリージョン単位
全ての商⽤リージョンで利⽤可能
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Global Secondary Index (GSI)
Partition Key属性の代わりとなる
Partition Keyをまたいで検索を⾏うためのインデックス
元のテーブルとキャパシティは別で管理
A1
(PK)
A2 A3 A4 A5
GSIs A5
(PK)
A4
(Sort)
A1
(table key)
A3
(projected)
Table
INCLUDE A3
A4
(PK)
A5
(Sort)
A1
(table key)
A2
(projected)
A3
(projected) ALL
A2
(PK)
A1
(table key)
KEYS_ONLY
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
GSI利⽤例:全体友だちリストの検索⽤
マッピング⽤GSIで
次郎さんの友達は誰がい
る?と⾔った逆引きが検索
可能
つながりからの検索⽤GSIで
テニスで太郎さんや幸⼦さ
んと繋がっている⼈は誰が
いる?が検索可能
)
(
K IK
K GK
F
(
IK K
GK K
F
(
K IK
K GK
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
メンテナンスフリー
もしこれらを管理するコストが無ければ他に何が出来るか?
セキュリティ
OSパッチ適用
DBパッチ適用
アクセスコントロール
監査
暗号化
コンプライアンス対応
耐久性
サーバ, ラック, データセンタ維持
HW障害に伴うデータコピー
バックアップ・リストア
可用性
高可用性を実現する設計
モニタリング
クロスリージョンレプリケーション
性能
パフォーマンスチューニング
インデックス設計、作成
In-memory上でキャッシュ維持
拡張性
キャパシティプランニング
ホスト構築、投入作業
障害ホストの修復、撤去作業
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
DynamoDB on-demand
DynamoDBで今までcapacity unitをprovisionし
て利用する必要があったがpay-per-requestモ
デルでの利用が可能に
既存テーブルでもどちらを利用するか選択可
能、再変更も可能
料金例としてVirginia Regionの場合
Write request : 100万回につき$1.25
Read request : 100万回につき$0.25
利用した分のストレージ課金は従来どおり
全ての商用リージョンで利用可能
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
“処理遅延がDynamoDBに移行したことで1秒から100ミ
リ秒に減少するのが確認出来ました。 DynamoDBが
いかにして高効率でミッションクリティカルなシス
テムの基盤として機能できるかを示しました。”
—Mike Thomas
Amazon
Amazon.comで何かを購入するたび
に内部では多くのシステムが稼働
し,日々何億ものアクティブなワー
クフローを処理している
OracleからDynamoDBへ:
• 顧客体験の改善: ワークフローの処理
時間が1秒程度から100msまで改善
• コスト削減: スケーリングとメンテナ
ンスのオペレーションコストが1/10
に減少
• 複雑さとリスクを軽減: 300ものOracle
DBホストを削減
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
データモデリングについて
• NoSQLはRDBとは特性が異なるので、それらを理解した上で適所でうまく
活⽤する
• NoSQL, DynamoDB の特徴を理解した上でテーブルを設計する
Ø 以下のドキュメントも参考に
DynamoDB のベストプラクティス
https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/best-
practices.html
Ø Advanced Design Patterns for DynamoDB
https://www.youtube.com/watch?v=HaEPXoXVf2k
Ø DynamoDB グローバルセカンダリインデックスを使⽤してクエリの
パフォーマンスを向上させ、コストを削減する⽅法
https://aws.amazon.com/jp/blogs/news/how-to-use-dynamodb-global-secondary-indexes-
to-improve-query-performance-and-reduce-costs/
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
https://www.slideshare.net/AmazonWebServicesJapan/db-144577033
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
NoSQL Workbench for Amazon DynamoDB(preview)
• Data modeler
• Visualizer
• Operation builder
の3つの機能を提供
GUIによるデータモデルの構築、視覚化、
データ操作を⽀援
Win/Mac共に対応
オペレーションと同じ処理をするコードを⽣
成する機能も対応(現在Python,Javascript,Javaに
対応予定)
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Data modeler
スキーマの設計、作成したデータの
import/exportに対応
Table、GSIの設定にも対応
TableのPartition Key、Sort Key、各Attributeの
Data typeなどが⼀覧化されて表⽰出来る
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Visualizer
Data modelerで作成したスキーマを元にテス
トデータの作成・変更、DynamoDBへの
commitなどのオペレーションが可能
テストデータを含めて表⽰することでどうい
うtable構造になるのか、GSIはどのようなデー
タで⽣成されるのか、などが可視化される
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Operation builder
既存tableに対してテーブルの⼀覧表⽰、
データの管理、各種API操作、各種API操
作のサンプルアプリケーションコード⽣
成が可能
接続に必要なIAM権限設定は必要
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Operation builder
Build operationsでは
• Update Item
• Put Item
• Delete Item
• Query
• Scan
• TransactWriteItems
の操作が可能
それぞれの操作で必要なオプションを設定す
る事も可能
複数条件などの設定も可能
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
⾃⼰紹介
桑野 章弘(くわの あきひろ)
• シニアソリューションアーキテクト
• 主にメディア系のお客様を担当しております。
• 元渋⾕のインフラエンジニア
• 好きなAWSのサービス
• Amazon DocumentDB, Amazon Route53, Amazon S3, Amazon Aurora
• twitter: @kuwa_tw
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB
(with MongoDB Compatibility)
Fast, scalable, and fully managed MongoDB-compatible database service
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
クライアント
アプリケーション データベース
JSON
!=
ドキュメント指向データベース以前のデータ連携
Relational
JSONはデータ連
携のデファクト
に
アプリケーショ
ンはデータベー
スから返ってく
るデータと
JSONの整合性
を取る
整合性のためにオ
ブジェクトリレー
ショナルマッパー
(ORM)が必要
対応コスト増
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
クライアント
アプリケーション データベース
JSON
≒
ドキュメント指向データベースのデータ連携
JSON-Like
JSONはデータ連
携のデファクト
に
アプリケーショ
ンはドキュメン
トデータベース
のJSONの整合
性を取るのは最
小限ですむ
ORMを使う必要も
限定的となる
対応コスト低:ドキュ
メントデータベースは
この問題への一つの解
となりうる
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
ドキュメント指向データベース
• JSON-likeなデータ
• ドキュメントはより⾃然な
形でデータを表現可能
• 柔軟性のあるスキーマ、イ
ンデックス
• Javascriptで表現可能な柔軟
なクエリ
{
id: 1,
name: ”kuwano",
age: 41,
email: ”kuwanoa@amazon.com",
promotions: ["new user", "5%", ”curry lover"],
memberDate: 2015-9-27,
shoppingCart: [
{product:"abc", quantity:2, cost:19.99},
{product:"edf", quantity:3, cost: 2.99}
]
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
ドキュメントデータベースのユースケース
モバイル
アプリ
リテール
&
マーケ
ティング
ユーザ
プロファイル
カタログ
コンテンツ管理 パーソナライ
ゼーション
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
ドキュメントデータベースのユースケース
ゲームのユーザプロフィール
{
id: 181276,
username: "sue1942",
name: {first: "Susan",
last: "Benoit"}
}
{
id: 181276,
username: "sue1942",
name: {first: "Susan",
last: "Benoit"},
ExplodingAcorns: {
hi_score: 3185400,
global_rank: 5139,
bonus_levels: true
},
promotions: ["new user","5%",”acorn lover"]
}
トロフィーを追加
スコアやランクを追加
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Fast, scalable, fully managed MongoDB-compatible database service
Amazon DocumentDB
秒間100万リクエスト実行可
ストレージレイヤでI/Oを最適
化
数分でスケールアウト&ス
ケールアップ
TLS、Encryption at rest
(カスタママネージドキー使用)
PCI, ISO, SOC2, HIPAAなど認
証
SLAの提供
必要な分、使った分だけの課
金体系
リードレプリカの昇格による
自動フェイルオーバ
S3へのストリームバックアッ
プ
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB の特徴
• マネージドドキュメントデータベースサービス
• JSON-likeなデータ群をマネージドする⽤途に特化したデータストア
• MongoDBとの互換性
• MongoDB 3.6 系互換API対応
• ⾼可⽤性
• ミッションクリティカルワークロードを⼤規模に運⽤する場合に効果的
• ⾼パフォーマンス
• ストレージとコンピュートを分離し⾼いパフォーマンスを実現
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB アーキテクチャ
• 3つのチャレンジ
• コンピュートとストレー
ジの分離
• パーティションへのデー
タ分散
• 6コピーとクオラムによ
るデータの堅牢性
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
コンピュートとストレージの分離
• コンピュートとストレージを分離することで個別に最適なスケールを⾏うこ
とができる
コンピュートのスケール
ストレージのスケール
コンピュートレイヤ
ストレージレイヤ
API
Query Processor
Caching
Logging + Storage
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
パーティションへのデータ分散
Distributed storage volume
パーティションへのデータ分散
AZ1 AZ2 AZ3
Logging + Storage
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Logging + Storage
Distributed storage volume
AZ1 AZ2 AZ3
データを3つのAZに6コピーする
6コピーとクオラムによるデータの堅牢性
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Distributed storage volume
AZ1 AZ2 AZ3
AWS Region
Availability Zone 1 Availability Zone 2 Availability Zone 3
Reads
Reads
Reads
Writes
Writes
Writes
Instance
(primary)
Instance
(replica)
Instance
(replica)
Amazon DocumentDB: エンドポイント
クラスタエンドポイント リーダーエンドポイント
書き込みノードを示すクラスタ
エンドポイントとリードレプリ
カを示すリーダーエンドポイン
トが存在
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB: スケーリング
Distributed storage volume
AZ1 AZ2
読み込みキャパシティのスケールをしたい場合
AZ3
最大15台のリードレプリカ, 100万リード/sec
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Amazon DocumentDB: 障害復旧
インスタンス障害からの復旧
Distributed storage volume
AZ1 AZ2 AZ3
インスタンス障害時は他のイン
スタンスへとフェイルオーバす
ることで障害復旧を行う
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Distributed storage volume
Availability Zone 1 Availability Zone 2 Availability Zone 3
Instance
(primary)
Instance
(replica)
Instance
(replica)
Amazon S3
Amazon DocumentDB: バックアップ
ストリーミングバックアップ
データベースへの性能影響のないストリーミングバックアップ
スナップショット
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
MongoDBの⼤規模構成例
mongod
• データノード
mongoc
• シャーディング情報を保存
する特殊なデータノード
mongos
• シャーディング時に適切な
シャードへと処理を振り分
けるルーティングプロセス
mongod
App + mongos
mongoc
mongoc:シャ
ーディング情報
の格納
mongos:
シャードルーター
適切なシャードへの割
り振り
mongod:実際のデータ
の格納
赤の囲みが1シャード
となり、シャード単
位で処理をオフロー
ドする
AZ AZ AZ各AZにノー
ド配置
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
MongoDBの⼤規模構成例
mongod
• データノード
mongoc
• シャーディング情報を保存
する特殊なデータノード
mongos
• シャーディング時に適切な
シャードへと処理を振り分
けるルーティングプロセス
mongod
App + mongos
mongoc
mongoc:シャ
ーディング情報
の格納
mongos:
シャードルーター
適切なシャードへの割
り振り
mongod:実際のデータ
の格納
赤の囲みが1シャード
となり、シャード単
位で処理をオフロー
ドする
AZ AZ AZ各AZにノー
ド配置
大規模なMongoDBはシャード構
成を組むことが多い
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Distributed storage volume
AZ1 AZ2 AZ3
AWS Region
Availability Zone 1 Availability Zone 2 Availability Zone 3
Reads
Reads
Reads
Writes
Writes
Writes
Instance
(primary)
Instance
(replica)
Instance
(replica)
Amazon DocumentDB: アーキテクチャ再掲
クラスタエンドポイント リーダーエンドポイント
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
何故シャーディングが必要ない?
読み込みスケール
シャードしたい要因
書き込みスケール
ストレージスケール
15台までのリードレプリカ
インスタンスのスケールアップが容易
DocumentDBでの対応
64TBまでのストレージ自動拡張
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• mongoDBのレプリカセットと互換性を
もった形でDocumentDBにアクセスでき
るモード
• アプリケーションからは rs0 というレプ
リカセットとして⾒える
• ドライバの互換性確保
レプリカセットモード rs0:PRIMARY> rs.status()
{
"set" : "rs0",
"date" : ISODate("2019-08-23T00:56:44Z"),
"myState" : 1,
"members" : [
{
"_id" : 0,
"name" : " docdb-example-002.abc.us-east-
1.docdb.amazonaws.com:27017 ",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 1547391
},
{
"_id" : 1,
"name" : "docdb-example-001.abc.us-east-
1.docdb.amazonaws.com:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"self" : true,
"uptime" : 1547391
}
],
"ok" : 1
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• Amazon DocumentDB のAudit logをCloudWatch Logs に直接転送可能
• データ定義⾔語 (DDL)、認証、認可、およびユーザー管理イベントが保存
される
• Filter Patternを設定しMetricsを作成することが可能なため、CloudWatchを利⽤
したアラートの発報も可能
監査ログ送信
DDL
UME
Auth Create event string
Create event string
Create event string Amazon CloudWatch
Logs
Amazon DocumentDB
https://docs.aws.amazon.com/ja_jp/documentdb/latest/developerguide/event-auditing.html
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• CloudWatchメトリクスに各種情報からクエリチューニングやスケールアウト、
アップを判断
• 主要なメトリクス⼀覧
モニタリング
メトリクス(一部) 説明
CPUUtilization CPU 使用率
Freeable Memory インスタンスで使用可能な RAM の量
Swap Usage インスタンスによって使用されているスワップスペースの量
Read IOPS、Write IOPS 1秒あたりのディスク読み取りまたは書き込みオペレーションの平均数
Read Latency、Write Latency読み取りまたは書き込みオペレーションの平均時間
Read Throughput、Write
Throughput
1 秒あたりのディスク読み取りまたは書き込みデータの平均量
Disk Queue Depth
ディスクに対する読み取りまたは書き込み待機中の I/O オペレーションの
数
Network Receive Throughput
、Network Transmit
Throughput
1 秒あたりのインスタンスに対する送信または受信ネットワークトラ
フィックのレート (メガバイト単位)。
DB Connections DB インスタンスに接続されたクライアントセッションの数
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
スロークエリ分析
• ⼀定以上遅いクエリについてしきい値(デフォルト100ms)以上の時間がか
かったオペレーションがCloudWatch Logsへ記録される
• 記録されるのは実⾏時間とクエリプラン
• Amazon DocumentDB のプロファイリングデータの分析には、CloudWatch Logs
Insights も活⽤できる
Query Time & Query Plan
Amazon
CloudWatch Logs
Amazon
DocumentDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
• MongoDB Ver.3.6 とのAPI互換性あり
• Aggregation Pipeline や、インデックス、演算⼦などの現状の対応状況について
は下記ドキュメントを参照
MongoDBとの互換性
https://docs.aws.amazon.com/ja_jp/documentdb/latest/developerguide/functional-differences.html
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
DocumentDB Index Tool
• 既存のmongoDBのインデック
ス情報をExport & Checkする事
が可能
• DocumentDBとの互換性確認
• サポートされていないイン
デックスタイプのインデック
ス、コレクションのチェック
などを実施
https://github.com/awslabs/amazon-documentdb-tools
# 対応していないCapped Collectionの場合
"testdatabase-logs-001": {
”access_logs": {
"unsupported_collection_options": [
"capped"
]
}
}
# 対応していないIndexの長さが63バイトを超えている場合
"testdatabase-001": {
"testcollection_hogehoge": {
"testcollection_hogehoge_id_1_hogehogehoge_1": {
"exceeded_limits": {
"<collection>$<index> greater than 63 characters":
"testcollection_hogehoge$testcollection_hogehoge_id_1_ho
gehogehoge_1"
}
}
}
}
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
まとめ
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
AWS Purpose-Builtデータベース
Relational Key-value Document In-memory Graph Time-series Ledger
DynamoDB NeptuneAmazon RDS
Aurora CommercialCommunity
Timestream QLDBElastiCacheDocumentDB
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Purpose built
The right tool for the right job
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark
Thank you!
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark