Slide 1

Slide 1 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. D E V D AY

Slide 2

Slide 2 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 貴⽅のツールボックスにねじこみ たい︕ドキュメントデータベース のススメ Akihiro Kuwano A - 4 - 1 Amazon DocumentDB Specilist Solutions Architect

Slide 3

Slide 3 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介 桑野 章弘(くわの あきひろ) • ソリューションアーキテクト • Amazon DocumentDB担当をしております • 好きなAWSのサービス •Amazon Route53, Amazon S3, Amazon Aurora •Amazon DocumentDB

Slide 4

Slide 4 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ⾃⼰紹介 桑野 章弘(くわの あきひろ) • ソリューションアーキテクト • Amazon DocumentDB担当をしております • 好きなAWSのサービス •カレーも好きです

Slide 5

Slide 5 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 本セッションについて • 今⽇持ち帰っていただくこと • ドキュメントデータベースの使い所について学ぶ • ドキュメントデータベースのアプリ開発の例について学ぶ • 話さないこと • AWSサービスの細かい説明

Slide 6

Slide 6 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベースとは ドキュメントデータベースと開発 ドキュメントデータベースとAWSサービス 簡単にAPIを作ってみよう(DEMO) 例えばこんな使い道 まとめ Agenda

Slide 7

Slide 7 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベース とは

Slide 8

Slide 8 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベースとは ドキュメントデータベース(ドキュメン トストア)は、XML、JSONをはじめとし た半構造化データ(=ドキュメント情 報)を保存、検索、管理するために設計 されたデータベース RDBMSでいうと以下の対応 • データベース=データベース • テーブル=コレクション • レコード=ドキュメント Database Collection Document 1 Document 2 { Key: Value, Key: Value } { Key: Value, Key: Value } ・ ・ ・

Slide 9

Slide 9 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベースの利点 柔軟かつ⾃然にデータを表現 できるJSON ⼀般的なアプリケーションデー タモデルとして利⽤できる JSON JSONデータをそのままデータ ベースに保存 JSONに対して柔軟なIndexを作 成することも可能 アドホック、集計クエリを実⾏ { name: ”kuwano", age: 44, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] }

Slide 10

Slide 10 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベース と開発

Slide 11

Slide 11 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベースと開発 • 前述の通りドキュメントデータベースにはJSONを格納しそのJSON に対して⾃由なクエリを実⾏できる • その利点を活⽤することで開発におけるメリットを享受できる • 開発スピードの⾼速化 • 変化に強い開発 • データの可視性の⾼さ • 柔軟なクエリ

Slide 12

Slide 12 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 開発スピードの⾼速化 開発全体におけるデータモデリングに 必要な時間が多く占めており、特に RDBMSにおいては専⾨のエンジニア にお願いするパターンなどもあり⼀定 の時間をかける必要がある ドキュメントデータベースは⾃由なデ ータ形式を持つことでモデリングの時 間を削減することが可能、要件定義の ブラッシュアップなど、より重要な作 業に時間を使うことができる つくりやすいぞ ・・・︕︖

Slide 13

Slide 13 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データモデリングの戦略 • 参照(正規化) • 埋め込み(⾮正規化) • ゲームスコアの共有サイ トを例に ID ユーザ名 年齢 email 登録⽇ 10001 kuwano 44 kuwano a@exam ple.com 2015-9- 27 ユーザーマスタ ID ハイスコア ランク 10001 3185400 5139 ユーザスコア ID 称号 10001 Curry Lover 10001 New user 称号

Slide 14

Slide 14 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データモデリングの戦略︓埋め込み • 1ドキュメントに埋め込む { name: ”kuwano", age: 44, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] }

Slide 15

Slide 15 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データモデリングの戦略︓埋め込み • 1ドキュメントに埋め込む { name: ”kuwano", age: 44, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] } ユーザマスタ ユーザスコア 称号

Slide 16

Slide 16 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データモデリングの戦略︓参照 { _id: ”abcde”, name: ”kuwano", age: 44, email: ”kuwanoa@example.com", memberDate: 2015-9-27 promotion: [10001, 10002], userScore: 1001 } { _id: ”1001”, name: ”kuwano", hi_score: 3185400, gamerank: 5139 } { _id: ”10001”, promotions: "new user" } ユーザーマスタ 称号 ユーザスコア { _id: ”10002”, promotions: ”curry lover" } 参照 参照 参照

Slide 17

Slide 17 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データモデリングを考える 実現したい内容から逆に考えて⾏ってモデルを作成する 得たい結果からモデリングする 参照か埋め込みか 最初は埋め込みで考える 埋め込みでは問題が出る場合に参照を考える パフォーマンス vs シンプルさ まずはシンプルさを⼤事に︕ データ モデリング ・・・

Slide 18

Slide 18 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 変化に強い開発 スキーマレスで柔軟なデータをもつことが可 能、それによって様々な仕様の変化にも柔軟 に対応可能 { name: ”kuwano", age: 45, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] } db. users.find({“name”: kuwano})

Slide 19

Slide 19 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 変化に強い開発 スキーマレスで柔軟なデータをもつことが可 能、それによって様々な仕様の変化にも柔軟 に対応可能 { name: ”kuwano", age: 45, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] } { name: ”kuwano", age: 45, email: ”kuwanoa@example.com", memberDate: 2015-9-27, GameScores: [ { GameName: ”⽣き抜け︕Kuwano", UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] }, { GameName: ”スマッシュKuwanoブラザーズ", UserScore: { hi_score: 100, gamerank: 50001 }, promotions: [] } ] } New バージョン db. users.find({“name”: kuwano}) データ仕様は変わったが データ取得⽅法は変わらない

Slide 20

Slide 20 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. データの可読性 JSONでデータを持つことができるため、データを⾒る際に何のデータ がどうなっているか、などを把握しやすい ⼈がデータを読んだ場合の可読性の⾼さはドキュメントデータベースの メリットとなる { name: ”kuwano", age: 45, email: ”kuwanoa@example.com", memberDate: 2015-9-27, UserScore: { hi_score: 3185400, gamerank: 5139 }, promotions: ["new user", ”curry lover"] } ID ユーザ名 年齢 email 登録⽇ 10001 kuwano 44 kuwanoa@exampl e.com 2015-9-27 ID ハイスコア ランク 10001 3185400 5139 10002 1125420 2234 ユーザーマスタ ユーザスコア ID 称号 10001 Curry Lover 10001 New user 10002 Beta User 称号

Slide 21

Slide 21 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 柔軟なクエリ JavaScriptベースのよりプログラ マブルなクエリを実⾏することが 可能 あまりに複雑すぎるクエリは可読 性を損なうので実⾏元のコードで ロジック作成を⾏うほうが良い場 合も多いが、適切に使えば⾼速な アプリ開発/運⽤に役⽴つ バッチ処理や、⼀時的な運⽤クエ リの投⼊、ダミーデータ投⼊など db.collection.find({ "age": { $gt: 30 } }).sort({ "name": 1 }).limit(5) function findUsersByAge(age) { return db.items.find({ "Age": { $gt: age } }); } let result = findUsersByAge(30); print(result) for(let i = 0; i < 1000; i++) { db.items.insert({ "id": i, "name": "item" + i }); } let cursor = db.items.find({ "name": "kuwanoa" }); while(cursor.hasNext()) { let doc = cursor.next(); db.items.updateOne({ "_id": doc._id }, { $set: { "flag": 1 } }); }

Slide 22

Slide 22 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 柔軟なクエリ JavaScriptベースのよりプログラ マブルなクエリを実⾏することが 可能 あまりに複雑すぎるクエリは可読 性を損なうので実⾏元のコードで ロジック作成を⾏うほうが良い場 合も多いが、適切に使えば⾼速な アプリ開発/運⽤に役⽴つ バッチ処理や、⼀時的な運⽤クエ リの投⼊、ダミーデータ投⼊など db.collection.find({ "age": { $gt: 30 } }).sort({ "name": 1 }).limit(5) function findUsersByAge(age) { return db.items.find({ "Age": { $gt: age } }); } let result = findUsersByAge(30); print(result) for(let i = 0; i < 1000; i++) { db.items.insert({ "id": i, "name": "item" + i }); } let cursor = db.items.find({ "name": "kuwanoa" }); while(cursor.hasNext()) { let doc = cursor.next(); db.items.updateOne({ "_id": doc._id }, { $set: { "flag": 1 } }); } “age”が30より⼤きく物を 検索、結果を“name”の昇 順でソート、最初の5つの ドキュメントを返す 1000個のデータをfor⽂で ループしながらInsertして いく “age”が指定した値より⼤き いドキュメントを検索する関 数を定義。その関数を使⽤し てクエリを実⾏(複雑なロ ジックをコードで⼊れること が可能) “items”コレクションの “name”が“kuwanoa”の各ド キュメントに“flag”フィール ドが順に更新・追加され、そ の値が1に設定される

Slide 23

Slide 23 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ドキュメントデータベース とAWSサービス

Slide 24

Slide 24 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Aurora Amazon RDS Amazon DynamoDB Amazon DocumentDB Amazon Timestream Amazon Neptune Amazon ElastiCache Amazon QLDB Amazon Keyspaces リレーショナル 参照整合性、 ACIDトランザ クション、 schema-on- wirte キーバリュー ⾼スループット、 低レイテンシの read/write、 制限のない拡張性 ドキュメント ドキュメントを 格納し、クエリ利⽤ により任意の属性に 対して⾼速にアクセ ス インメモリ キーを利⽤して マイクロ秒の レイテンシでクエ リ グラフ 時系列 時間経過に従って 計測されるデータを 収集、蓄積、処理 台帳 データ間の関係性を ⾼速、容易に作成、 探索 ワイドカラム 完全、不変かつ検証 可能な、アプリ ケーションデータに 対するすべての変更履歴 従来のアプリ ケーション、ERP 、CRM、会計 トラフィックの 多いウェブアプリ、 eコマースシステム、 リアルタイム⼊札 コンテンツ管理、 カタログ、ユーザー プロファイル キャッシュ、 セッション管理、 ゲームのリーダー ボード、地理空間 アプリケーション 不正検出、ソーシャ ルネットワーク、 レコメンデーション エンジン IoTアプリケーション 、イベント トラッキング 記録システム、 サプライチェーン、 ヘルスケア、 トランザクション AWS サービス 主なユー スケース スケーラブルで、 可⽤性が⾼い、 マネージドなApache Cassandra互換サービス 低レイテンシな アプリケーションの構築、 Cassandra ベースの アプリケーションを クラウドに移⾏ Amazon MemoryD B for Redis AWS の マネージドデータベースサービス

Slide 25

Slide 25 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Aurora Amazon RDS Amazon DynamoDB Amazon DocumentDB Amazon Timestream Amazon Neptune Amazon ElastiCache Amazon QLDB Amazon Keyspaces リレーショナル 参照整合性、 ACIDトランザ クション、 schema-on- wirte キーバリュー ⾼スループット、 低レイテンシの read/write、 制限のない拡張性 ドキュメント ドキュメントを 格納し、クエリ利⽤ により任意の属性に 対して⾼速にアクセ ス インメモリ キーを利⽤して マイクロ秒の レイテンシでクエ リ グラフ 時系列 時間経過に従って 計測されるデータを 収集、蓄積、処理 台帳 データ間の関係性を ⾼速、容易に作成、 探索 ワイドカラム 完全、不変かつ検証 可能な、アプリ ケーションデータに 対するすべての変更履歴 従来のアプリ ケーション、ERP 、CRM、会計 トラフィックの 多いウェブアプリ、 eコマースシステム、 リアルタイム⼊札 コンテンツ管理、 カタログ、ユーザー プロファイル キャッシュ、 セッション管理、 ゲームのリーダー ボード、地理空間 アプリケーション 不正検出、ソーシャ ルネットワーク、 レコメンデーション エンジン IoTアプリケーション 、イベント トラッキング 記録システム、 サプライチェーン、 ヘルスケア、 トランザクション AWS サービス 主なユー スケース スケーラブルで、 可⽤性が⾼い、 マネージドなApache Cassandra互換サービス 低レイテンシな アプリケーションの構築、 Cassandra ベースの アプリケーションを クラウドに移⾏ Amazon MemoryD B for Redis AWS の マネージドデータベースサービス

Slide 26

Slide 26 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon DocumentDB フ ル マ ネ ー ジ ド の ネ イ テ ィ ブ J S O N ド キ ュ メ ン ト デ ー タ ベ ー ス § コンピュートとストレージは それぞれ独⽴でスケール § 数分で15のリードレプリカま でスケール、毎秒数百万読み 込みリクエスト、ミリ秒のレ イテンシー § Elastic Clustersは、毎秒数百 万の読み込み、書き込みリク エスト、4PBのストレージま でスケール スケール § ハードウェアプロビジョニン グ不要、セットアップ簡単、 ⾃動バックアップ。データ ベース運⽤における、付加価 値を⽣まない重労働から解放 される フルマネージド § MongoDB Community Edition 3.6/4.0/5.0との互換 性 § 同⼀のMongoDB APIs、ドラ イバー、ツールが利⽤可能 MongoDB互換 § ⾼可⽤性、信頼性 § Global Clusters はリージョ ン全体の停⽌からのリカバ リー、ローカルレイテンシー によるグローバルな読み込み を提供 § VPCのみ、AWS KMSによる ストレージ暗号化、TLS通信 暗号化 § AWSのセキュリティベストプ ラクティスの適⽤ エンタープライズ

Slide 27

Slide 27 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 簡単にAPIを作ってみよう(DEMO)

Slide 28

Slide 28 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 簡単にAPIを作ってみよう Rest APIは現在様々な場⾯で⼀般的ん 使われるAPIですが、ドキュメントデ ータベースはRest APIを作るのに向い ているデータベースとなります AWSのサービス群を使って簡単にRest APIを作ってみましょう︕ なんかAPI作っとこーって思ったとき に数⼗分でAPIが作れるとなんか便利 ですよね︖ つくりやすいぞ ・・・︕︖

Slide 29

Slide 29 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 全体構成 AWS App Runner Amazon DocumentDB (with MongoDB compatibility) AWS Cloud Virtual private cloud (VPC) users API Access AWS Cloud Development Kit (AWS CDK) AWS Secrets Manager Amazon Elastic Container Registry (Amazon ECR) Developpers Docker Push

Slide 30

Slide 30 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS環境の作成 AWS App Runner Amazon DocumentDB (with MongoDB compatibility) AWS Cloud Virtual private cloud (VPC) users API Access AWS Cloud Development Kit (AWS CDK) AWS Secrets Manager Amazon Elastic Container Registry (Amazon ECR) IaCで各環境を作成していく Developpers Docker Push

Slide 31

Slide 31 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS環境の作成

Slide 32

Slide 32 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Docker ファイル作成 AWS App Runner Amazon DocumentDB (with MongoDB compatibility) AWS Cloud Virtual private cloud (VPC) Users API Access AWS Cloud Development Kit (AWS CDK) AWS Secrets Manager Amazon Elastic Container Registry (Amazon ECR) IaCで各環境を作成していく Developpers Docker Push Dockerファイルを作成しコ ンテナレジストリへPush

Slide 33

Slide 33 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Docker ファイル作成

Slide 34

Slide 34 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS App Ruunerへデプロイ AWS App Runner Amazon DocumentDB (with MongoDB compatibility) AWS Cloud Virtual private cloud (VPC) Users API Access AWS Cloud Development Kit (AWS CDK) AWS Secrets Manager Amazon Elastic Container Registry (Amazon ECR) IaCで各環境を作成していく Developpers Docker Push Dockerファイルを作成しコン テナレジストリ(ECR)へPush ECRにPushしたあとでAWS App Runnerへデプロイ

Slide 35

Slide 35 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS App Ruunerへデプロイ

Slide 36

Slide 36 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. APIアクセス確認 AWS App Runner Amazon DocumentDB (with MongoDB compatibility) AWS Cloud Virtual private cloud (VPC) Users API Access AWS Cloud Development Kit (AWS CDK) AWS Secrets Manager Amazon Elastic Container Registry (Amazon ECR) IaCで各環境を作成していく Developpers Docker Push Dockerファイルを作成しコン テナレジストリ(ECR)へPush ECRにPushしたあとでAWS App Runnerへデプロイ UserからRest APIに対してア クセスができるかを確認

Slide 37

Slide 37 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. APIアクセス確認 # DocumentDB データ確認 rs0:PRIMARY> db.items.find().pretty() { "_id" : ObjectId("64858604ac886b5c35429771"), "Name" : "testman", "Age" : 100 } { "_id" : ObjectId("6485867276ed3f073a790cdb"), "Name" : "kuwanoa", "Age" : 45 } # API データ投⼊(curl) $ curl -X 'POST' 'https://apidemo.us-east-1.awsapprunner.com/items' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"Age": 45,"Name": "kuwanoa"}’ { "message": "Item added" } $curl -X 'POST' 'https://apidemo.us-east-1.awsapprunner.com/items' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"Age": 100,"Name": "testman"}' { "message": "Item added" } # API データ確認 (curl) $ curl https://apidemo.us-east-1.awsapprunner.com/items [ { "Age": 45, "Name": "kuwanoa" }, { "Age": 100, "Name": "testman" } ] findはSQLでいえばSELECT データがそのまま投⼊されて いることがわかる

Slide 38

Slide 38 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 例えばこんな使い道

Slide 39

Slide 39 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. ユーザ/システム パラメータ管理⽤のAPI アプリケーションの設定情報をいれ ておくパラメータ管理のAPIを簡単 に実装可能 各アプリケーションの動作変更や、 マルチテナントなど場合の設定情報 など詳細な設定を柔軟に格納、操作 、確認することが可能 API API API { _id: “API_A”, config_flag_a: 1, endpoints: [ “https://〜”, … ], descriptions: {” 説明…" }, }, { _id: “API_B”, config_flag_a: 0, (略) }, 共通の各種設定を格納 API

Slide 40

Slide 40 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. アンケート管理システムなど アンケート作成システムや、記事管理シス テムなどへの⾃由な要素追加を⾏なう この例では⾃由な数のアンケート項⽬を⾃ 由に作成、JSONの配列をへ要素追加でア イテム追加が可能 { _id name: ” アンケートフォーム", surveyItems: [ { surveyType: “text”, text: “今⽇の感想をおしえてください”, maxChar: 1000, required: 0 }, { surveyType: “radio button”, text: “セッションはわかりやすかったです か︖”, itemCount: 5, required: 1 }, ] } 今⽇の感想をおしえてください セッションはわかりやすかったですか︖ わかりやすい<->わかりにくい 5 1 項⽬を配列にPushしていく だけで独⾃のアンケートが作 られるモデルが作れる

Slide 41

Slide 41 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 機械学習のデータストア 機械学習の実⾏の際に扱われるデータはJSON で表現するのが便利なデータであったり、ス キーマレスなデータが多い(特徴量、、、モ デルパラメータ、、、推論結果など、、、) これらのデータをドキュメントデータベース に格納し推論APIや、モデル作成時に使⽤す る { "userId": ”kuwanoa”, "features": { "favoriteCategory": ”Electronics”, "averageRating": 4.3, "numberOfRatings": 12, "categoryRatios": { "Electronics": 0.5, "Books": 0.3, "Movies": 0.2 } }, "itemFeatures": [ { "itemId": ”12345”, "averageRating": 4.2, "numberOfRatings": 100, "numberOfRaters": 80 }, { "itemId": ”67890”, "averageRating": 4.5, "numberOfRatings": 120, "numberOfRaters": 90 } // 以下省略 ] } API レコメンデーション したい︕ Amazon SageMaker 特徴量作るよ

Slide 42

Slide 42 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. IoTデバイスの情報管理⽤ IoTデバイスから送信される多量のデータ を受けるためのAPIを提供 バケットパターンや、コンピューテッド パターンを使ってデータを効率よく格納 する 流量が多い場合はElastic Clustersを使った マネージドシャーディングも活⽤可能 { node_id: 12345, start_date: ISODate("2023-06-21T10:00:00.000Z"), end_date: ISODate("2023-06-21T10:59:59.000Z"), measurements: [ { timestamp: ISODate("2023-06-21T10:00:00.000Z"), cpuUtil: 10 }, { timestamp: ISODate("2023-06-21T10:01:00.000Z"), cpuUtil: 15 }, … { timestamp: ISODate("2023-06-21T10:45:00.000Z"), cpuUtil: 80 } ], transaction_count: 45, avgCpuutil: 25, maxCpuutil: 80, minCpuutil: 5 } API IoTノード群 1データを1オブジェ クトではなくある程度 の塊にして保存するデ ザインパターン 1データを1オブジェ クトではなくある程度 の塊にして保存するデ ザインパターン

Slide 43

Slide 43 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. IoTデバイスの情報管理⽤ IoTデバイスから送信される多量のデータ を受けるためのAPIを提供 バケットパターンや、コンピューテッド パターンを使ってデータを効率よく格納 する 流量が多い場合はElastic Clustersを使った マネージドシャーディングも活⽤可能 { node_id: 12345, start_date: ISODate("2023-06-21T10:00:00.000Z"), end_date: ISODate("2023-06-21T10:59:59.000Z"), measurements: [ { timestamp: ISODate("2023-06-21T10:00:00.000Z"), cpuUtil: 10 }, { timestamp: ISODate("2023-06-21T10:01:00.000Z"), cpuUtil: 15 }, … { timestamp: ISODate("2023-06-21T10:45:00.000Z"), cpuUtil: 80 } ], transaction_count: 45, avgCpuutil: 25, maxCpuutil: 80, minCpuutil: 5 } API IoTノード群 Amazon DocumentDB Elastic Clusters 最⼤32シャード のマネージドシ ャード

Slide 44

Slide 44 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Todoアプリとかも 余談ですがバケットパターンだとTodoアプリ なんかに使っても効率よくデータを保管する ことができます 100万TODOがあったとして(普通そんなな いですが)も時間的な偏りが少なければ⼀度 に処理するオブジェクト数を削減することが 可能です API // object 1 { "buckets": [ { "timestamp": "2023-06-20T00:00:00", "todos": [ { "_id": 1, "title": ”play Zelda", "status": ”ongoing" }, { "_id": 2, "title": "Finish homework", "status": ”pending" } ] } ] } // object 2 { "buckets": [ { "timestamp": "2023-06-20T01:00:00", "todos": [ { "_id": 3, "title": ”Play Pokeca", "status": ”ongoing" } ] } ] }

Slide 45

Slide 45 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめ

Slide 46

Slide 46 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. まとめ • ドキュメントデータベースを使って開発スピード/サービスの成⻑ス ピードを上げていきましょう︕ • AWSサービス群と連携することで簡単にAPIを作ったりできます︕ • お気軽にAWSのソリューションアーキテクトまでお聞きください︕

Slide 47

Slide 47 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you! © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.

Slide 48

Slide 48 text

© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Please complete the session survey © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.