© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Jun Kim
Database Expert Principal SA
AWS DocumentDB
Hands-on Session
Hyojeong Han
TAM
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
2
Agenda
• What is Amazon DocumentDB?
• DocumentDB Overall Architecture
• DocumentDB Replication
• 1st hands-on
• DocumentDB Modeling
• 2nd hands-on
• Q&A
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
3
Amazon DocumentDB (with MongoDB compatibility)
Fully managed and scalable
document database service that
supports MongoDB workloads
Scalable
Fully managed
MongoDB API
compatible
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Amazon DocumentDB (with MongoDB compatibility)
Backups enabled by default
Durable by default
Built-in high availability
Security best practices by default
Automatic patching
Monitoring and alerting
Fully managed
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
Amazon DocumentDB (with MongoDB compatibility)
Scalable
Scale compute in minutes
Storage and IO autoscaling
Storage scales to 128TiB
Scale out to 15 replicas for millions of reads
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
6
Amazon DocumentDB (with MongoDB compatibility)
Applications, drivers, and tools can be used with
Amazon DocumentDB with little or no change
Supports hundreds of APIs, operators, and stages
Continually working backward from customers
to deliver the capabilities they need
MongoDB API
compatible
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
7
When shoud you use a document database?
Amazon
DocumentDB makes
it easy to
store, query, and
index JSON data
JSON data
Operational and
analytics workloads
Ad hoc query
capabilities
Flexible indexing
Flexible schema for
fast iteration
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Architecture
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
9
DocumentDB Architecture
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
db.foo.find({}) {"x":1}
AZ 1 AZ 2 AZ 3
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
10
DocumentDB Architecture
Separation of
storage / compute
How would you
build a cloud-native
database
architecture?
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
11
DocumentDB Architecture
Separation of
storage / compute
API
Query processor
Caching
Logging
Storage
Log writes
Decouple compute and storage
Compute layer
Storage layer
Separation of
storage and
compute
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
12
DocumentDB Architecture
Separation of
storage / compute
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
Instance
(primary)
Reads
Writes
r6g.large
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
13
DocumentDB Architecture
Separation of
storage / compute
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
Instance
(primary)
Reads
Writes
r6g.large
Instance
(replica)
Reads
r6g.large
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Replication
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
15
DocumentDB Replication
Replication
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
16
DocumentDB Replication
Replication
db.foo.insert({’x’:1})
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
17
DocumentDB Replication
Replication
db.foo.insert({’x’:1})
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
ACK
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
18
DocumentDB Replication
Replication
db.foo.insert({’x’:1}) ACK
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
Eventual
consistency
Eventual
consistency
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
19
DocumentDB Replication
Replication
ACK
db.foo.insert({’x’:1})
db.foo.insert({’x’:1}) ACK
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
Eventual
consistency
Eventual
consistency
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
20
DocumentDB Replication
Replication
Instance
(replica)
Reads
Instance
(primary)
Reads
Writes
Instance
(replica)
Reads
Distributed storage volume
AZ 1 AZ 2 AZ 3
Compute
Storage
Eventual
consistency
Eventual
consistency
db.foo.find({}) {‘x’:1}
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
1st Hands-on
• Create DocumentDB Cluster
• CRUD
• Scale Cluster
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Modeling
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
23
Describe the application requirements
1. Workload Define
• Estimate inventory of 100,000 products, in the first year (product data to be kept forever)
• Estimate a number of 10,000 customers, in the first year (customer account data to be kept forever)
• Order and reviews data needs to be kept for 5 years.
• Estimated read/write ratio is 80% / 20%
2. Read & Write Queries
• Insert new products
• Update existing products
• Insert customers
• Insert reviews added by customers
• Insert orders
• Update orders
• Read products
• Read orders
• Read reviews
• Read customer data
• Run reports
Example
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
24
Describe the application requirements
CRUD Frequency Type
New Products
Added
300/day Write
Product views 6500/sec Read
New customer
added
30/day Write
Customer logs in to
website
30 user logins/sec Read
New order added 10/hour Write
New review added 5/hour Write
Run reports 1/day Read
op Desc Type
Max
latency
Avg Freq
/sec
Max Freq
/sec
w1 New Product added or
updated
I/U < 500ms 5 10
w2 Customer creates
account
I < 100ms 1 3
w3 New review added for
product
I < 200ms 3 12
w4
Customer creates order I 10ms 12 30
w5 Customer adds
products to order
U 20ms 16 48
R1
Customer logs into app R 5ms 32 64
R2 Customer views a
specific product
R 1m 250 6500
R3 Customer views their
orders
R
20ms 20 80
R4 Analytics report
executed
R < 300sec <1 2
R5
Customer views review R 5ms 12 36
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
25
Describe the application requirements
ü List the actual requirements of the application.
This is where you define what the application is supposed to do and what data will be stored in the
database
ü Estimate the data size
ü Quantify the operations, such as the total queries ran against the database, and how many reads
versus writes are expected
ü Qualify those operations, think about the most important queries and latency requirements of those
queries
ü Identify consistency requirements and tolerance to stale data
- Key Takeaways : Find out how the data will be used for workload.
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
26
Identify Relationship
- Think about the relationship between collection ( Reference or Embed )
Relationship :
• One-to-one
• One-to-many
• Many-to-many
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
27
Identify Relationship
- Think about the relationship between collection ( Reference or Embed )
Referenced vs Embed
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
28
Identify Relationship
- Referencing
Procedure
{
"_id" : 333,
"date" : "2003-02-09T05:00:00"),
"hospital" : “County Hills”,
"patient" : “John Doe”,
"physician" : “Stephen Smith”,
"type" : ”Chest X-ray",
”result" : 134
}
Results
{
“_id” : 134
"type" : "txt",
"size" : NumberInt(12),
"content" : {
value1: 343,
value2: “abc”,
…
}
}
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
29
Identify Relationship
- Embedding
Procedure
{
"_id" : 333,
"date" : "2003-02-09T05:00:00"),
"hospital" : “County Hills”,
"patient" : “John Doe”,
"physician" : “Stephen Smith”,
"type" : ”Chest X-ray",
”result" : {
"type" : "txt",
"size" : NumberInt(12),
"content" : {
value1: 343,
value2: “abc”,
…
}
}
}
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
30
Identify Relationship
- Referencing vs Embedding
Pros vs Cons
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
31
Apply Design Patterns
- Attribute pattern
Before Apply Pattern After Apply Pattern
{
“_id”: <objectId>,
“productid”: <productid>,
“name”: <string>,
“description”: <string>,
“size”: <string>,
“weight”:<int>,
“color”:<string>,
“packaging”:<string>
}
{
“_id”: <objectId>,
“productid”: <productid>,
“name”: <string>,
“description”: <string>,
“attributes”: [
{“key”: ”size”, “value”:<string>},
{“key”: ”weight”, “value”:<int>},
{“key”: ”color”, “value”:<string>},
{“key”: ”packaging”, “value”:<string>},
]
}
v Benefits
Leverage Indexing - attributes.key
Easy to expand qualifier
• { descriptor: "price", qualifier: "euros", value: Decimal(100.00) }
{ descriptor: "price", qualifier: “won”, value: Decimal(80000.00) }
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
32
Apply Design Patterns
- Bucket pattern
Before Apply Pattern After Apply Pattern
{
“_id”: <objectId>,
“productid”: <productid>,
“name”: <string>,
“description”: <string>,
“attributes”: [
{“key”: ”size”, “value”:<string>},
{“key”: ”weight”, “value”:<int>},
{“key”: ”color”, “value”:<string>},
{“key”: ”packaging”, “value”:<string>},
]
}
v Benefits
Practical benefits of the document model ( 1:N )
Reduce indexing size
Increased speed in extracting relevant data
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
33
Apply Design Patterns
- Subset pattern
Before Apply Pattern After Apply Pattern
v Benefits
Maintain small working set ( increasing cache efficiency )
Read Performance Increase
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
AWS DATA & AI ROADSHOW 2024
34
One Takeaway
- you must remember
Query Together
Should be
Saved Together !
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
2nd Hands-on
• How to model the document
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
QnA = True
if QnA:
doQuestions()
else:
doSurvey()
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024
© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!

[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습

  • 1.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Jun Kim Database Expert Principal SA AWS DocumentDB Hands-on Session Hyojeong Han TAM
  • 2.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 2 Agenda • What is Amazon DocumentDB? • DocumentDB Overall Architecture • DocumentDB Replication • 1st hands-on • DocumentDB Modeling • 2nd hands-on • Q&A
  • 3.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 3 Amazon DocumentDB (with MongoDB compatibility) Fully managed and scalable document database service that supports MongoDB workloads Scalable Fully managed MongoDB API compatible
  • 4.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Amazon DocumentDB (with MongoDB compatibility) Backups enabled by default Durable by default Built-in high availability Security best practices by default Automatic patching Monitoring and alerting Fully managed
  • 5.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 Amazon DocumentDB (with MongoDB compatibility) Scalable Scale compute in minutes Storage and IO autoscaling Storage scales to 128TiB Scale out to 15 replicas for millions of reads
  • 6.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 6 Amazon DocumentDB (with MongoDB compatibility) Applications, drivers, and tools can be used with Amazon DocumentDB with little or no change Supports hundreds of APIs, operators, and stages Continually working backward from customers to deliver the capabilities they need MongoDB API compatible
  • 7.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 7 When shoud you use a document database? Amazon DocumentDB makes it easy to store, query, and index JSON data JSON data Operational and analytics workloads Ad hoc query capabilities Flexible indexing Flexible schema for fast iteration
  • 8.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Architecture
  • 9.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 9 DocumentDB Architecture Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume db.foo.find({}) {"x":1} AZ 1 AZ 2 AZ 3
  • 10.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 10 DocumentDB Architecture Separation of storage / compute How would you build a cloud-native database architecture? Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage
  • 11.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 11 DocumentDB Architecture Separation of storage / compute API Query processor Caching Logging Storage Log writes Decouple compute and storage Compute layer Storage layer Separation of storage and compute
  • 12.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 12 DocumentDB Architecture Separation of storage / compute Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage Instance (primary) Reads Writes r6g.large
  • 13.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 13 DocumentDB Architecture Separation of storage / compute Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage Instance (primary) Reads Writes r6g.large Instance (replica) Reads r6g.large
  • 14.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Replication
  • 15.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 15 DocumentDB Replication Replication Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage
  • 16.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 16 DocumentDB Replication Replication db.foo.insert({’x’:1}) Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage
  • 17.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 17 DocumentDB Replication Replication db.foo.insert({’x’:1}) Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage ACK
  • 18.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 18 DocumentDB Replication Replication db.foo.insert({’x’:1}) ACK Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage Eventual consistency Eventual consistency
  • 19.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 19 DocumentDB Replication Replication ACK db.foo.insert({’x’:1}) db.foo.insert({’x’:1}) ACK Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage Eventual consistency Eventual consistency
  • 20.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 20 DocumentDB Replication Replication Instance (replica) Reads Instance (primary) Reads Writes Instance (replica) Reads Distributed storage volume AZ 1 AZ 2 AZ 3 Compute Storage Eventual consistency Eventual consistency db.foo.find({}) {‘x’:1}
  • 21.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 1st Hands-on • Create DocumentDB Cluster • CRUD • Scale Cluster
  • 22.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Modeling
  • 23.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 23 Describe the application requirements 1. Workload Define • Estimate inventory of 100,000 products, in the first year (product data to be kept forever) • Estimate a number of 10,000 customers, in the first year (customer account data to be kept forever) • Order and reviews data needs to be kept for 5 years. • Estimated read/write ratio is 80% / 20% 2. Read & Write Queries • Insert new products • Update existing products • Insert customers • Insert reviews added by customers • Insert orders • Update orders • Read products • Read orders • Read reviews • Read customer data • Run reports Example
  • 24.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 24 Describe the application requirements CRUD Frequency Type New Products Added 300/day Write Product views 6500/sec Read New customer added 30/day Write Customer logs in to website 30 user logins/sec Read New order added 10/hour Write New review added 5/hour Write Run reports 1/day Read op Desc Type Max latency Avg Freq /sec Max Freq /sec w1 New Product added or updated I/U < 500ms 5 10 w2 Customer creates account I < 100ms 1 3 w3 New review added for product I < 200ms 3 12 w4 Customer creates order I 10ms 12 30 w5 Customer adds products to order U 20ms 16 48 R1 Customer logs into app R 5ms 32 64 R2 Customer views a specific product R 1m 250 6500 R3 Customer views their orders R 20ms 20 80 R4 Analytics report executed R < 300sec <1 2 R5 Customer views review R 5ms 12 36
  • 25.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 25 Describe the application requirements ü List the actual requirements of the application. This is where you define what the application is supposed to do and what data will be stored in the database ü Estimate the data size ü Quantify the operations, such as the total queries ran against the database, and how many reads versus writes are expected ü Qualify those operations, think about the most important queries and latency requirements of those queries ü Identify consistency requirements and tolerance to stale data - Key Takeaways : Find out how the data will be used for workload.
  • 26.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 26 Identify Relationship - Think about the relationship between collection ( Reference or Embed ) Relationship : • One-to-one • One-to-many • Many-to-many
  • 27.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 27 Identify Relationship - Think about the relationship between collection ( Reference or Embed ) Referenced vs Embed
  • 28.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 28 Identify Relationship - Referencing Procedure { "_id" : 333, "date" : "2003-02-09T05:00:00"), "hospital" : “County Hills”, "patient" : “John Doe”, "physician" : “Stephen Smith”, "type" : ”Chest X-ray", ”result" : 134 } Results { “_id” : 134 "type" : "txt", "size" : NumberInt(12), "content" : { value1: 343, value2: “abc”, … } }
  • 29.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 29 Identify Relationship - Embedding Procedure { "_id" : 333, "date" : "2003-02-09T05:00:00"), "hospital" : “County Hills”, "patient" : “John Doe”, "physician" : “Stephen Smith”, "type" : ”Chest X-ray", ”result" : { "type" : "txt", "size" : NumberInt(12), "content" : { value1: 343, value2: “abc”, … } } }
  • 30.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 30 Identify Relationship - Referencing vs Embedding Pros vs Cons
  • 31.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 31 Apply Design Patterns - Attribute pattern Before Apply Pattern After Apply Pattern { “_id”: <objectId>, “productid”: <productid>, “name”: <string>, “description”: <string>, “size”: <string>, “weight”:<int>, “color”:<string>, “packaging”:<string> } { “_id”: <objectId>, “productid”: <productid>, “name”: <string>, “description”: <string>, “attributes”: [ {“key”: ”size”, “value”:<string>}, {“key”: ”weight”, “value”:<int>}, {“key”: ”color”, “value”:<string>}, {“key”: ”packaging”, “value”:<string>}, ] } v Benefits Leverage Indexing - attributes.key Easy to expand qualifier • { descriptor: "price", qualifier: "euros", value: Decimal(100.00) } { descriptor: "price", qualifier: “won”, value: Decimal(80000.00) }
  • 32.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 32 Apply Design Patterns - Bucket pattern Before Apply Pattern After Apply Pattern { “_id”: <objectId>, “productid”: <productid>, “name”: <string>, “description”: <string>, “attributes”: [ {“key”: ”size”, “value”:<string>}, {“key”: ”weight”, “value”:<int>}, {“key”: ”color”, “value”:<string>}, {“key”: ”packaging”, “value”:<string>}, ] } v Benefits Practical benefits of the document model ( 1:N ) Reduce indexing size Increased speed in extracting relevant data
  • 33.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 33 Apply Design Patterns - Subset pattern Before Apply Pattern After Apply Pattern v Benefits Maintain small working set ( increasing cache efficiency ) Read Performance Increase
  • 34.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 AWS DATA & AI ROADSHOW 2024 34 One Takeaway - you must remember Query Together Should be Saved Together !
  • 35.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2nd Hands-on • How to model the document
  • 36.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. QnA = True if QnA: doQuestions() else: doSurvey()
  • 37.
    © 2024, AmazonWeb Services, Inc. or its affiliates. All rights reserved. AWS DATA & AI ROADSHOW 2024 © 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you!