Amazon Dynamo DB 활용하기 - 강민석 :: AWS Database Modernization Day 온라인

awskorea 1,854 views 31 slides Aug 07, 2020
Slide 1
Slide 1 of 31
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

About This Presentation

발표 영상 다시보기: https://kr-resources.awscloud.com/data-databases-and-analytics/%EC%A7%80%EA%B8%88-%EB%8B%B9%EC%9E%A5-dynamo-db-%ED%99%9C%EC%9A%A9%ED%95%98%EA%B8%B0-%EA%B0%95%EB%AF%BC%EC%84%9D-aws-database-modernization-day-%EC%98%A8%EB%9D%BC%EC%9D%B8-2

DynamoDB는 대량의 트래픽에...


Slide Content

© 2020, Amazon Web Services, Inc. or its Affiliates. © 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Databases Modernization Day
Sr. Database Specialist SA
DynamoDB활용하기
강민석

© 2020, Amazon Web Services, Inc. or its Affiliates.
강연중질문하는 방법
Go to Webinar “Chat/채팅” 창에자신이질문한
내역이표시됩니다 .기본적으로 모든질문은
공개로답변됩니다만 본인만답변을받고싶으면
(비공개)라고하고질문해주시면됩니다.
본컨텐츠는 고객의편의를위해AWS 서비스설명을위해온라인세미나용으로 별도로제작, 제공된것입니다 . 만약AWS
사이트와 컨텐츠상에서차이나불일치가 있을경우, AWS 사이트(aws.amazon.com)가우선합니다 . 또한AWS 사이트
상에서한글번역문과 영어원문에차이나불일치가 있을경우(번역의지체로인한경우등포함), 영어원문이우선합니다 .
AWS는본컨텐츠에 포함되거나 컨텐츠를 통하여고객에게 제공된일체의정보, 콘텐츠, 자료, 제품(소프트웨어 포함) 또는서비스를 이용함으로 인하여발생하는 여하한종류의손해에
대하여어떠한책임도지지아니하며 , 이는직접손해, 간접손해, 부수적손해, 징벌적손해및결과적손해를포함하되 이에한정되지 아니합니다 .
고지사항(Disclaimer)

© 2020, Amazon Web Services, Inc. or its Affiliates.
Table of contents
•DynamoDB이해하기
•DynamoDB실습

© 2020, Amazon Web Services, Inc. or its Affiliates. © 2020, Amazon Web Services, Inc. or its Affiliates.
DynamoDB이해하기

© 2020, Amazon Web Services, Inc. or its Affiliates.
Data Platform portfolio
Redshift
Data
warehousing
EMR
Hadoop +
Spark
Athena
Interactive
analytics
Kinesis Data
Analytics Real
time
Elasticsearch
Service
Operational
Analytics
RDS
MySQL, PostgreSQL,
MariaDB, Oracle, SQL
Server
Aurora
MySQL,
PostgreSQL
QuickSight SageMaker
DynamoDB
Key value
ElastiCache
Redis, Memcached
Neptune
Graph
Timestream
Time Series
QLDB
Ledger
Database
S3/Glacier
Glue
ETL & Data
Catalog
Lake Formation
Data Lakes
Database Migration Service | Snowball | Snowmobile | Kinesis Data Firehose | Kinesis Data Streams
Data Movement
Analytics Databases
Database, Business Intelligence & Machine Learning
Data Lake
Managed
Blockchain
Blockchain
Templates
Blockchain
RDS on VMware
DocumentDB
Document

© 2020, Amazon Web Services, Inc. or its Affiliates.
Amazon에서의NoSQL 역사
Dec 2004:
Database
scalability
challenges
Oct 2007:
Dynamo paper
published
Jan 2012:
DynamoDB
general
availability
Q3 2016:
DynamoDB leader
in Gartner MQ,
Forrester Wave
Today:
Tier 0 service
powering most of
Amazon

© 2020, Amazon Web Services, Inc. or its Affiliates.
DynamoDB란무엇인가 ?
•2007년에Amazon에서“Dynamo Model”
으로처음출시
•2012년도에DynamoDB로서비스됨
•Key-Value기반의NoSQL Database
•성능: Low latency
•용량: Almost infinite capacity
•관리: No need to worry, Easy
•확장: 완벽한(Seamless)scalability
•고가용성 : High Durability & Availability
•쉬운Planning: (via throughput
parameters)
Service-oriented architecture of
Amazon’s platform

© 2020, Amazon Web Services, Inc. or its Affiliates.
Amazon DynamoDB
Highly available
and durable
Consistently fast at any scale
Fully managed
Secure
Integrates with AWS Lambda,
Amazon Redshift, and more
Cost-effective
3개의AZ에3 copy
복제
한자리milli-second
latency
Serverless로관리
비용절감
IAM보안사용 AWS 서비스와 통합
사용한만큼비용

© 2020, Amazon Web Services, Inc. or its Affiliates.
How DynamoDBworks?

© 2020, Amazon Web Services, Inc. or its Affiliates.
Data modeling: SQL vs. NoSQL
SQL

© 2020, Amazon Web Services, Inc. or its Affiliates.
Data modeling: SQL vs. NoSQL
NoSQLSQL

© 2020, Amazon Web Services, Inc. or its Affiliates.
Partition Key
Mandatory
Key-value access pattern
Determines data distribution
Optional
Model 1:N relationships
Enables rich query capabilities
A1
(partition key)
A2
(sort key)
A3A4 A7
A1
(partition key)
A2
(sort key)
A6A4 A5
A1
(partition key)
A2
(sort key)
A1
(partition key)
A2
(sort key)
A3A4 A5
SortKey
Table
Items
DynamoDB테이블
Attributes
All items for a partition key
==, <, >, >=, <=
“begins with”
“between”
sorted results
counts
top/bottom N values
paged responses

© 2020, Amazon Web Services, Inc. or its Affiliates.
Partitioning
00
55
AA
FF
Hash(1) = 7B
Orders
Partition A
33.33 % Keyspace
33.33 % Provisioned Capacity
Partition B
33.33 % Keyspace
33.33 % Provisioned Capacity
Partition C
33.33 % Keyspace
33.33 % Provisioned Capacity
Hash.MIN = 0
Hash.MAX = FF
Keyspace
Hash(2) = 48
Hash(3) = CD
DynamoDBtable
OrderId: 1
CustomerId: 1
ASIN: [B00X4WHP5E]
OrderId: 2
CustomerId: 4
ASIN: [B00OQVZDJM]
OrderId: 3
CustomerId: 3
ASIN: [B00U3FPN4U]
•1 Partition = 10G, 1 Item = Max 400 KB, 1 Partition 에는25,000 개의Item이들어감
•1 Partition 의최고RCU는3,000. 최고WCU는1,000 입니다.

© 2020, Amazon Web Services, Inc. or its Affiliates.
Partition: Sort Key 예
Partition 300:0 FF:∞
Hash (2) = 48
Customer# = 2
Order# = 10
Item = Pen
Customer# = 2
Order# = 11
Item = Shoes
Customer# = 1
Order# = 10
Item = Toy
Customer# = 1
Order# = 11
Item = Boots
Hash (1) = 7B
Customer# = 3
Order# = 10
Item = Book
Customer# = 3
Order# = 11
Item = Paper
Hash (3) = CD
55 A9:∞54:∞ AAPartition 1 Partition 2

© 2020, Amazon Web Services, Inc. or its Affiliates.
Local secondary index(LSI)
A1
(partition)
A3
(sort)
A2
(item key)
A1
(partition)
A2
(sort)
A3A4A5
LSIs
A1
(partition)
A4
(sort)
A2
(item key)
A3
(projected)
Table
KEYS_ONLY
INCLUDE A3
A1
(partition)
A5
(sort)
A2
(item key)
A3
(projected)
A4
(projected)
ALL
•10 GB max per partition key, i.e. LSIs limit the # of
range keys!
•Table당5개
LSI
•Alternate sort key attribute
•Index is local to a partition key

© 2020, Amazon Web Services, Inc. or its Affiliates.
RCUs/WCUs provisioned separately
for GSIs
•Alternate partition (+sort) key
•Use composite sort keys for compound indexes
•Can be added or removed anytime
GSI: 테이블당 20개제약
Global secondary index(GSI)
A1
(partition)
A2 A3 A4 A5
Table
A5
(partition)
A4
(sort)
A1
(item key)
A3
(projected)
INCLUDE A3
A4
(partition)
A5
(sort)
A1
(item key)
A2
(projected)
A3
(projected)
ALL
A2
(partition)
A1
(itemkey)
KEYS_ONLY
GSIs
Online indexing

© 2020, Amazon Web Services, Inc. or its Affiliates.
Data types
Type DynamoDB Type
String String
Integer, Float Number
Timestamp Number or String
Blob Binary
Boolean Bool
Null Null
List List
Set
Set of String, Number, or
Binary
Map Map

© 2020, Amazon Web Services, Inc. or its Affiliates.
테이블속성
읽기/쓰기용량모드
Provisioned ModeOn-Demand Mode
•애플리케이션에서 수행할것으로예상되는 읽기
및쓰기처리량을 지정할필요가없음
•테이블에 대해수행하는 읽기및쓰기에대해
요금이부과
•워크노드에 따라읽기/쓰기용량이변경됨
•사용예
•알수없는워크로드를 포함하는 테이블을
새로만들경우
•애플리케이션 트래픽이 예측불가능한
경우
•사용한만큼에대해서만 지불하는
요금제를 사용하려는 경우
•테이블의 읽기용량단위(RCU) 및쓰기용량
단위(WCU)의처리량을 지정
•DynamoDB는이정보를사용하여 처리량요구
사항에맞는충분한시스템리소스확보
•DynamoDBAuto Scaling에서테이블의 처리
용량을관리하도록 허용할수도있음

© 2020, Amazon Web Services, Inc. or its Affiliates.
DynamoDBAuto Scaling
• 목표사용률—테이블의 목표사용률을 입력합니다 .
• 최소프로비저닝 용량—Auto Scaling 범위의하한을입력합니다 .
• 최대프로비저닝 용량—Auto Scaling 범위의상한을입력합니다 .
• 글로벌보조인덱스에 동일한설정적용—이옵션을기본설정(활성화)으로유지합니다 .
Throughput automatically adapts to your actual traffic
WithAuto ScalingWithoutAuto Scaling

© 2020, Amazon Web Services, Inc. or its Affiliates.
Burst capacity is built in
0
400
800
1200
1600
Capacity Units
Time
ProvisionedConsumed
“Save up” unused capacity
Consume saved up capacity
Burst: 300 seconds
(1200 ×300 = 360k CU)
DynamoDB “saves” 300 seconds of
unused capacity per partition

© 2020, Amazon Web Services, Inc. or its Affiliates.
효과적으로 파티션키를설계
•효과적인 버스트용량사용
•5분(300초)에해당하는 미사용읽기및쓰기용량을비축
•높은트래픽파티션에 대한처리량향상
•특정파티션키에대한트래픽이 3,000RCU, 1,000WCU를초과하지 않도록유지
•핫파티션의 Item 분산
https://docs.aws.amazon.com/ko_kr/amazondynamodb/latest/developerguide/best-practices.html

© 2020, Amazon Web Services, Inc. or its Affiliates.
Throttling
•Occurs if sustainedthroughput goes beyond
provisioned throughput per partition
•Possible causes
•Non-uniform workloads
•Hot keys/hot partitions
•Very large items
•Mixing hot data with cold data
•Remedy: Use TTL or a table per time
period
•Disable retries, write your own retry
code, and log all throttled or returned
keys

© 2020, Amazon Web Services, Inc. or its Affiliates.
Data modeling: Hierarchical data structures as items
•Use composite sort key to define a hierarchy
•Highly selective result sets with sort queries
•Index anything, scales to any size
Primary Key
Attributes
ProductID type
Items
1 bookID
title author genre publisherdatePublished ISBN
Some Book JohnSmith Science Fiction Ballantine Oct-70 0-345-02046-4
2 albumID
title artist genre label studio releasedproducer
SomeAlbum SomeBand Progressive Rock Harvest Abbey Road 3/1/73 Somebody
2 albumID:trackID
title length music vocals
Track1 1:30 Mason Instrumental
2 albumID:trackID
title length music vocals
Track 2 2:43 Mason Mason
2 albumID:trackID
title length music vocals
Track3 3:30 Smith Johnson
3 movieID
title genre writer producer
Some Movie Scifi Comedy JoeSmith 20th Century Fox
3 movieID:actorID
name character image
Some Actor Joe img2.jpg
3 movieID:actorID
name character image
SomeActress Rita img3.jpg
3 movieID:actorID
name character image
SomeActor Frito img1.jpg

© 2020, Amazon Web Services, Inc. or its Affiliates.
… or as documents (JSON)
•JSON data types (M, L, BOOL, NULL)
•Document SDKs available
•400 KB maximum item size (limits hierarchical data structure)
Primary Key
Attributes
ProductID
Items
1
id title author genre publisherdatePublished ISBN
bookID Some Book SomeGuy Science FictionBallantine Oct-700-345-02046-4
2
id title artist genre Attributes
albumID Some Album SomeBand Progressive Rock
{ label:"Harvest", studio: "Abbey Road", published: "3/1/73", producer: "Pink
Floyd", tracks: [{title: "Speak to Me", length: "1:30", music: "Mason", vocals:
"Instrumental"},{title: ”Breathe", length: ”2:43", music: ”Waters, Gilmour,
Wright", vocals: ”Gilmour"},{title: ”On the Run", length: “3:30", music: ”Gilmour,
Waters", vocals: "Instrumental"}]}
3
id title genre writer Attributes
movieID Some Movie Scifi Comedy JoeSmith
{ producer: "20th Century Fox", actors: [{ name: "Luke Wilson", dob: "9/21/71",
character: "Joe Bowers", image: "img2.jpg"},{ name: "Maya Rudolph", dob:
"7/27/72", character: "Rita", image: "img1.jpg"},{ name: "Dax Shepard", dob:
"1/2/75", character: "Frito Pendejo", image: "img3.jpg"}]

© 2020, Amazon Web Services, Inc. or its Affiliates. © 2020, Amazon Web Services, Inc. or its Affiliates.
DynamoDB활용-Demo

© 2020, Amazon Web Services, Inc. or its Affiliates.

© 2020, Amazon Web Services, Inc. or its Affiliates.
Lab1 –실습환경 구성

© 2020, Amazon Web Services, Inc. or its Affiliates.
Lab2 –DynamoDB테이블생성및활용

© 2020, Amazon Web Services, Inc. or its Affiliates.
Lab3 –성능테스트(WCU/RCU –On-Demand)

© 2020, Amazon Web Services, Inc. or its Affiliates.
AWS Database Modernization Day에
참석해주셔서 대단히감사합니다 .
[email protected]
twitter.com/AWSKorea
facebook.com/amazonwebservices.ko
youtube.com/user/AWSKorea
slideshare.net/awskorea
twitch.tv/aws
저희가준비한내용, 어떻게보셨나요 ?
더나은세미나를 위하여설문을꼭작성해주시기바랍니다 .

© 2020, Amazon Web Services, Inc. or its Affiliates. © 2020, Amazon Web Services, Inc. or its Affiliates.
Thank you!