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

awskorea 122 views 37 slides Jul 02, 2024
Slide 1
Slide 1 of 37
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37

About This Presentation

Amazon DocumentDB(MongoDB와 호환됨)는 빠르고 안정적이며 완전 관리형 데이터베이스 서비스입니다. Amazon DocumentDB를 사용하면 클라우드에서 MongoDB 호환 데이터베이스를 쉽게 설치, 운영 및 규모를 조정할 수 있습니다. Amazon DocumentDB를 ...


Slide Content

© 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.
JunKim
DatabaseExpertPrincipalSA
AWSDocumentDB
Hands-onSession
Hyojeong Han
TAM

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024AWS DATA & AI ROADSHOW 2024
2
Agenda
•What is Amazon DocumentDB?
•DocumentDB Overall Architecture
•DocumentDB Replication
•1
st hands-on
•DocumentDB Modeling
•2
nd hands-on
•Q&A

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS DATA & AI ROADSHOW 2024
11
DocumentDB Architecture
Separation of
storage / compute
API
Query processor
Caching
Logging
Storage
Log writesDecouple 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS DATA & AI ROADSHOW 2024
19
DocumentDB Replication
Replication
ACKdb.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 2024AWS 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.
1
st 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 2024AWS 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 2024AWS DATA & AI ROADSHOW 2024
24
Describe the application requirements
CRUD Frequency Type
New Products
Added
300/day Write
Product views6500/sec Read
New customer
added
30/day Write
Customer logs in to
website
30 user logins/secRead
New order added10/hour Write
New review added5/hour Write
Run reports 1/day Read
op DescType
Max
latency
Avg Freq
/sec
Max Freq
/sec
w1New Product added or
updated
I/U< 500ms 5 10
w2Customer creates
account
I < 100ms 1 3
w3New review added for
product
I < 200ms 3 12
w4
Customer creates orderI 10ms 12 30
w5Customer adds
products to order
U 20ms 16 48
R1
Customer logs into appR 5ms 32 64
R2Customer views a
specific product
R 1m 250 6500
R3Customer views their
orders
R
20ms 20 80
R4Analytics report
executed
R < 300sec <1 2
R5
Customer views reviewR 5ms 12 36

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS 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 2024AWS DATA & AI ROADSHOW 2024
33
Apply Design Patterns
- Subset pattern
Before Apply Pattern After Apply Pattern
v Benefits
Maintainsmallworkingset(increasingcacheefficiency)
Read Performance Increase

© 2024, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS DATA & AI ROADSHOW 2024AWS DATA & AI ROADSHOW 2024
34
OneTakeaway
- 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.
2
nd 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!