SlideShare a Scribd company logo
게임을 위한 DynamoDB 사례 및 팁
김일호 | Solutions Architect
박성원, Nexon Korea | 파트장
Agenda
§Tip 1. DynamoDB Index(LSI, GSI)
§Tip 2. DynamoDB Scaling
§Tip 3. DynamoDB Data Modeling
§Scenario based Best Practice
§Nexon use-case
Indexes
Scaling
Data Modeling
Best Practice
Use-case
Local secondary index (LSI)
§Alternate range key attribute
§Index is local to a hash key (or partition)
A1
(hash)
A3
(range)
A2
(table	key)
A1
(hash)
A2
(range)
A3 A4 A5
LSIs A1
(hash)
A4
(range)
A2
(table	key)
A3
(projected)
Table
KEYS_ONLY
INCLUDE	A3
A1
(hash)
A5
(range)
A2
(table	key)
A3
(projected)
A4
(projected)
ALL
10	GB	max	per	hash	key,	
i.e.	LSIs	limit	the	#	of	ran
ge	keys!
Global secondary index (GSI)
§Alternate hash (+range) key
§Index is across all table hash keys (partitions)
A1
(hash)
A2 A3 A4 A5
GSIs A5
(hash)
A4
(range)
A1
(table	key)
A3
(projected)
Table
INCLUDE	A3
A4
(hash)
A5
(range)
A1
(table	key)
A2
(projected)
A3
(projected) ALL
A2
(hash)
A1
(table	key) KEYS_ONLY
RCUs/WCUs	provisioned	se
parately	for	GSIs	
Online	indexing
How do GSI updates work?
Table
Primary	ta
ble
Primary	ta
ble
Primary	ta
ble
Primary	ta
ble
Global	Seco
ndary	Index
Client
2.	Asynchronous	
update	(in	progress)
If	GSIs	don’t	 have	enough	 write	capacity,	table	writes	will	be	throttled!
LSI or GSI?
§LSI can be modeled as a GSI
§If data size in an item collection > 10 GB, use GSI
§If eventual consistency is okay for your scenario, use GSI!
Indexes
Scaling
Data Modeling
Best Practice
Use-case
Scaling
§Throughput
§ Provision any amount of throughput to a table
§Size
§ Add any number of items to a table
§ Max item size is 400 KB
§ LSIs limit the number of range keys due to 10 GB limit
§Scaling is achieved through partitioning
Throughput
§Provisioned at the table level
§ Write capacity units (WCUs) are measured in 1 KB per second
§ Read capacity units (RCUs) are measured in 4 KB per second
§ RCUs measure strictly consistent reads
§ Eventually consistent reads cost 1/2 of consistent reads
§Read and write throughput limits are independent
WCURCU
Partitioning math
Number	of	Partitions
By	Capacity (Total	RCU	/	3000)	+	(Total	WCU	/	1000)
By	Size Total	Size	/	10	GB
Total	Partitions CEILING(MAX	(Capacity,	Size))
Partitioning example
Table	size	=	8	GB,	RCUs	=	5000,	WCUs	=	500
RCUs	per	partition	=	5000/3	=	1666.67
WCUs	per	partition	=	500/3	=		166.67
Data/partition	=	10/3	=	3.33	GB
RCUs	and	WCUs	are	uniformly	 sprea
d	across	partitions
Numberof	Partitions
By Capacity (5000	/	3000)	+	(500	/	1000)	=	2.17
By	Size 8 /	10	=	0.8
Total	Partitions CEILING(MAX	(2.17,	0.8))	=	3
Example: hot keys
Partition
Time
Heat
Example: periodic spike
Getting the most out of DynamoDB throughput
“To get the most out of
DynamoDB throughput, create
tables where the hash key
element has a large number of
distinct values, and values are
requested fairly uniformly, as
randomly as possible.”
—DynamoDB Developer Guide
§Space: access is evenly
spread over the key-
space
§Time: requests arrive
evenly spaced in time
What causes throttling?
§ If sustained throughput goes beyond provisioned throughput per partition
§ Non-uniform workloads
§ Hot keys/hot partitions
§ Very large bursts
§ Mixing hot data with cold data
§ Use a table per time period
§ From the example before:
§ Table created with 5000 RCUs, 500 WCUs
§ RCUs per partition = 1666.67
§ WCUs per partition = 166.67
§ If sustained throughput > (1666 RCUs or 166 WCUs) per key or partition, DynamoDB may
throttle requests
§ Solution: Increase provisioned throughput
Indexes
Scaling
Data Modeling
Best Practice
Use-case
1:1 relationships or key-values
§Use a table or GSI with a hash key
§Use GetItem or BatchGetItem API
§Example: Given an SSN or license number, get
attributes
Users	Table
Hash	key Attributes
SSN	=	123-45-6789 Email	=	johndoe@nowhere.com,	License =	TDL25478134
SSN	=	987-65-4321 Email	=	maryfowler@somewhere.com,	License =	TDL78309234
Users-Email-GSI
Hash	key Attributes
License =	TDL78309234 Email	=	maryfowler@somewhere.com,	SSN	=	987-65-4321
License =	TDL25478134 Email	=	johndoe@nowhere.com,	SSN	=	123-45-6789
1:N relationships or parent-children
§Use a table or GSI with hash and range key
§Use Query API
Example:
§ Given a device, find all readings between epoch X, Y
Device-measurements
Hash	Key Range	key Attributes
DeviceId	=	1 epoch	=	5513A97C Temperature	=	30,	pressure	=	90
DeviceId	=	1 epoch	=	5513A9DB Temperature	=	30,	pressure	=	90
N:M relationships
§Use a table and GSI with hash and range key elements
switched
§Use Query API
Example: Given a user, find all games. Or given a game,
find all users.
User-Games-Table
Hash	Key Range	key
UserId	=	bob GameId	=	Game1
UserId	=	fred GameId	=	Game2
UserId	=	bob GameId	=	Game3
Game-Users-GSI
Hash	Key Range	key
GameId	=	Game1 UserId	=	bob
GameId	=	Game2 UserId	=	fred
GameId	=	Game3 UserId	=	bob
Documents (JSON)
§ New data types (M, L, BOOL,
NULL) introduced to support
JSON
§ Document SDKs
§ Simple programming model
§ Conversion to/from JSON
§ Java, JavaScript, Ruby, .NET
§ Cannot index (S,N) elements
of a JSON object stored in M
§ Only top-level table attributes
can be used in LSIs and
GSIs without
Streams/Lambda
JavaScript DynamoDB
string S
number N
boolean BOOL
null NULL
array L
object M
Rich expressions
§Projection expression
§ Query/Get/Scan: ProductReviews.FiveStar[0]
§Filter expression
§ Query/Scan: #VIEWS > :num
§Conditional expression
§ Put/Update/DeleteItem: attribute_not_exists (#pr.FiveStar)
§Update expression
§ UpdateItem: set Replies = Replies + :num
Indexes
Scaling
Data Modeling
Best Practice
Use-case
Game logging
Storing time series data
Time series tables
Events_table_2015_April
Event_id
(Hash	key)
Timestamp
(range	key)
Attribute1 …. Attribute	N
Events_table_2015_March
Event_id
(Hash	key)
Timestamp
(range	key)
Attribute1 …. Attribute	N
Events_table_2015_Feburary
Event_id
(Hash	key)
Timestamp
(range	key)
Attribute1 …. Attribute	N
Events_table_2015_January
Event_id
(Hash	key)
Timestamp
(range	key)
Attribute1 …. Attribute	N
RCUs	=	1000
WCUs	=	100
RCUs	=	10000
WCUs	=	10000
RCUs	=	100
WCUs	=	1
RCUs	=	10
WCUs	=	1
Current	table
Older	tables
Hot	dataCold	data
Don’t	mix	hot	and	cold	data;	archive	cold	data	to	Amazon	S3
Important	when:
Use a table per time period
§Pre-create daily, weekly, monthly tables
§Provision required throughput for current table
§Writes go to the current table
§Turn off (or reduce) throughput for older tables
Dealing with time series data
Item shop catalog
Popular items (read)
Partition	1
2000	RCUs
Partition	K
2000	RCUs
Partition	M
2000	RCUs
Partition	50
2000	RCU
Scaling bottlenecks
Product	 A Product	 B
Gamers
ItemShopCatalog Table
SELECT Id, Description, ...
FROM ItemShopCatalog
Requests	Per	Second
Item	Primary	Key
Request	Distribution	Per	Hash	Key
DynamoDB	Requests
Partition	 1 Partition	 2
ItemShopCatalog Table
User
DynamoDB
User
Cache
popular	items
SELECT Id, Description, ...
FROM ProductCatalog
Requests	Per	Second
Item	Primary	Key
Request	Distribution	Per	Hash	Key
DynamoDB	Requests Cache	Hits
Multiplayer online gaming
Query filters vs.
composite key indexes
GameId Date Host Opponent Status
d9bl3 2014-10-02 David Alice DONE
72f49 2014-09-30 Alice Bob PENDING
o2pnb 2014-10-08 Bob Carol IN_PROGRESS
b932s 2014-10-03 Carol Bob PENDING
ef9ca 2014-10-03 David Bob IN_PROGRESS
Games	Table
Multiplayer online game data
Hash	key
Query for incoming game requests
§DynamoDB indexes provide hash and range
§What about queries for two equalities and a range?
SELECT * FROM Game
WHERE Opponent='Bob‘
AND Status=‘PENDING'
ORDER BY Date DESC
(hash)
(range)
(?)
Secondary	Index
Opponent Date GameId Status Host
Alice 2014-10-02 d9bl3 DONE David
Carol 2014-10-08 o2pnb IN_PROGRESS Bob
Bob 2014-09-30 72f49 PENDING Alice
Bob 2014-10-03 b932s PENDING Carol
Bob 2014-10-03 ef9ca IN_PROGRESS David
Approach 1: Query filter
BobHash	key Range	key
Secondary	Index
Approach 1: query filter
Bob
Opponent Date GameId Status Host
Alice 2014-10-02 d9bl3 DONE David
Carol 2014-10-08 o2pnb IN_PROGRESS Bob
Bob 2014-09-30 72f49 PENDING Alice
Bob 2014-10-03 b932s PENDING Carol
Bob 2014-10-03 ef9ca IN_PROGRESS David
SELECT * FROM Game
WHERE Opponent='Bob'
ORDER BY Date DESC
FILTER ON Status='PENDING'
(filtered	out)
Needle in a haystack
Bob
Important	when:
Use query filter
§Send back less data “on the wire”
§Simplify application code
§Simple SQL-like expressions
§ AND, OR, NOT, ()
Your index isn’t entirely selective
Approach 2: composite key
StatusDate
DONE_2014-10-02
IN_PROGRESS_2014-10-08
IN_PROGRESS_2014-10-03
PENDING_2014-09-30
PENDING_2014-10-03
Status
DONE
IN_PROGRESS
IN_PROGRESS
PENDING
PENDING
Date
2014-10-02
2014-10-08
2014-10-03
2014-10-03
2014-09-30
+ =
Secondary	Index
Approach 2: composite key
Opponent StatusDate GameId Host
Alice DONE_2014-10-02 d9bl3 David
Carol IN_PROGRESS_2014-10-08 o2pnb Bob
Bob IN_PROGRESS_2014-10-03 ef9ca David
Bob PENDING_2014-09-30 72f49 Alice
Bob PENDING_2014-10-03 b932s Carol
Hash	key Range	key
Opponent StatusDate GameId Host
Alice DONE_2014-10-02 d9bl3 David
Carol IN_PROGRESS_2014-10-08 o2pnb Bob
Bob IN_PROGRESS_2014-10-03 ef9ca David
Bob PENDING_2014-09-30 72f49 Alice
Bob PENDING_2014-10-03 b932s Carol
Secondary	Index
Approach 2: composite key
Bob
SELECT * FROM Game
WHERE Opponent='Bob'
AND StatusDate BEGINS_WITH 'PENDING'
Needle in a sorted haystack
Bob
Sparse indexes
Id	
(Hash)
User Game Score Date Award
1 Bob G1 1300 2012-12-23
2 Bob G1 1450 2012-12-23
3 Jay G1 1600 2012-12-24
4 Mary G1 2000 2012-10-24 Champ
5 Ryan G2 123 2012-03-10
6 Jones G2 345 2012-03-20
Game-scores-table
Award	
(Hash)
Id User Score
Champ 4 Mary 2000
Award-GSI
Scan	sparse	hash	GSIs
Important	when:
Replace filter with indexes
§Concatenate attributes to form useful
§secondary index keys
§Take advantage of sparse indexes
You want to optimize a query as much
as possible
Status + Date
Indexes
Scaling
Data Modeling
Best Practice
Use-case
Nexon Korea, 박성원 파트장
넥슨 모바일 게임 관련 데이터베이스 업무를 담당하고 있습니다.
DDB 사용현황
§HIT 메인 게임DB
• 27	Tables
• Various	Alarms
• Flexible	Dashboards
DDB, 이런 분에게 추천합니다.
§Capacity 산정
§Monitoring
§백업 및 복원
§Tips
https://i.ytimg.com/vi/C6U2M7ZkZI8/maxresdefault.jpg
Capacity 산정
§ 서비스 전 읽기/쓰기에 대한 패턴 테스트를 꼭 수행하세요.
§ 모든 패턴이 읽혀지진 않지만, 병목의 중심이 되는 대략적인 내용은
파악할 수 있습니다.
§ 동시 사용자 증가 속도를 꼭 염두에 두셔야 합니다. 대응하려는
순간 이미 서비스 불가일 수 있습니다.
Ø 2분 안에 800,000 증가
Ø 초당 RCUs	변환 시 13,000	증가
시간
읽
기
호
출
수
Capacity 변경
§웹콘솔, AWS앱, CLI 등으로 쉽게 Capacity 변경이
가능합니다.
§다만, 즉시 적용은 되지 않습니다. AWS에도 작업 시간을
주세요.
§대량의 RCUs, WCUs 변경이 필요한 경우는 미리
준비하는 것이 좋습니다.
Capacity 모니터링
§Cloud Watch 를 활용하세요.
§대시보드 및 알람 기능이 매우 유용합니다.
§초 단위 데이터까지 보기엔 어렵습니다. (1분 단위 Sum)
백업 및 복원
§ Export / Import 개념입니다.
§ Data Pipeline 을 사용하세요.
§ CLI 에 친숙해 지세요. 반복적인 작업을 쉽게 구현할 수
있습니다.
소소한 Tip
§Read / Write 캐시 레이어 도입을 고려하세요.
• Retry	시 지수 백오프 알고리즘을 도입하세요.
• Data	용량계획을 고려하세요.
http://cfile30.uf.tistory.com/image/221DF544538C11D62866E9
DDB 를 사용해보니…
§전통적인 RDB와 비교하여 손댈 것이 거의 없습니다.
§AWS Document 에 근거하여 개발하셔야 합니다.
§운영 시 Cloud Watch 및 CLI 가 많은 도움이 됩니다.
Thank you!

More Related Content

PPTX
Deep Dive with Spark Streaming - Tathagata Das - Spark Meetup 2013-06-17
PPTX
BigQuery Query Optimization クエリ高速化編
PDF
ログ管理のベストプラクティス
PPTX
CloudFront経由でのCORS利用
PDF
[2D1]Elasticsearch 성능 최적화
PDF
Dockerを利用したローカル環境から本番環境までの構築設計
PDF
webservice scaling for newbie
PDF
ビッグデータ処理データベースの全体像と使い分け
Deep Dive with Spark Streaming - Tathagata Das - Spark Meetup 2013-06-17
BigQuery Query Optimization クエリ高速化編
ログ管理のベストプラクティス
CloudFront経由でのCORS利用
[2D1]Elasticsearch 성능 최적화
Dockerを利用したローカル環境から本番環境までの構築設計
webservice scaling for newbie
ビッグデータ処理データベースの全体像と使い分け

What's hot (20)

PDF
Data Engineering 101
PDF
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
PDF
アクセスプラン(実行計画)の読み方入門
PDF
Hadoop/Spark で Amazon S3 を徹底的に使いこなすワザ (Hadoop / Spark Conference Japan 2019)
PDF
SQLアンチパターン読書会 4章 キーレスエンエントリ(外部キー嫌い)
PDF
[236] 카카오의데이터파이프라인 윤도영
PPTX
DynamoDB活用事例 株式会社マイネット
PDF
Elasticsearch勉強会#44 20210624
PPTX
Optimizing Apache Spark SQL Joins
PDF
AWS EMR Cost optimization
PPTX
Streaming platform Kafka in SK planet
PDF
AWS Lambdaを紐解く
PDF
Little Big Data #1. 바닥부터 시작하는 데이터 인프라
PDF
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
PDF
データ活用を加速するAWS分析サービスのご紹介
PDF
AWS Black Belt Techシリーズ AWS Management Console
PDF
Dynamic Partition Pruning in Apache Spark
PPTX
Introduction to Apache ZooKeeper
PDF
Amazon DynamoDB(初心者向け 超速マスター編)JAWSUG大阪
PDF
PostgreSQL Unconference #29 Unicode IVS
Data Engineering 101
Don’t Forget About Your Past—Optimizing Apache Druid Performance With Neil Bu...
アクセスプラン(実行計画)の読み方入門
Hadoop/Spark で Amazon S3 を徹底的に使いこなすワザ (Hadoop / Spark Conference Japan 2019)
SQLアンチパターン読書会 4章 キーレスエンエントリ(外部キー嫌い)
[236] 카카오의데이터파이프라인 윤도영
DynamoDB活用事例 株式会社マイネット
Elasticsearch勉強会#44 20210624
Optimizing Apache Spark SQL Joins
AWS EMR Cost optimization
Streaming platform Kafka in SK planet
AWS Lambdaを紐解く
Little Big Data #1. 바닥부터 시작하는 데이터 인프라
Amazon S3 Best Practice and Tuning for Hadoop/Spark in the Cloud
データ活用を加速するAWS分析サービスのご紹介
AWS Black Belt Techシリーズ AWS Management Console
Dynamic Partition Pruning in Apache Spark
Introduction to Apache ZooKeeper
Amazon DynamoDB(初心者向け 超速マスター編)JAWSUG大阪
PostgreSQL Unconference #29 Unicode IVS
Ad

Viewers also liked (20)

PDF
Dynamodb 삽질기
PDF
개발자가 알아야 할 Amazon DynamoDB 활용법 :: 김일호 :: AWS Summit Seoul 2016
PDF
DynamoDB를 이용한 PHP와 Django간 세션 공유 - 강대성 (피플펀드컴퍼니)
PDF
게임업계 IT 관리자를 위한 7가지 유용한 팁 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
PDF
Lambda를 활용한 서버없는 아키텍쳐 구현하기 :: 김기완 :: AWS Summit Seoul 2016
PDF
웹 이후의 세계 제3장
PDF
소셜카지노 초기런칭 및 실험결과 공유
PDF
HBase Schema Design - HBase-Con 2012
PDF
20131002 AWS Meister re:Generate - DynamoDB (Korean)
PDF
Amazon Redshift로 데이터웨어하우스(DW) 구축하기
PDF
관계형 데이터베이스의 새로운 패러다임 Amazon Aurora :: 김상필 :: AWS Summit Seoul 2016
PPTX
Bottled water 요약 설명 20151114
PDF
Amazon Aurora Deep Dive (김기완) - AWS DB Day
PDF
Amazon Aurora 100% 활용하기
PDF
Tutorial olap4j
PDF
2014.4.30 프라이머 개발자 모임 - 서버 장애 예방 및 대응 방법 공유
PPTX
디지털 인문학 데이터베이스 개론
PDF
다중성 확보, 시스템 안정화
PPTX
Compare DynamoDB vs. MongoDB
PDF
AWS Lambda 100% 활용하기 :: 김상필 솔루션즈 아키텍트 :: Gaming on AWS 2016
Dynamodb 삽질기
개발자가 알아야 할 Amazon DynamoDB 활용법 :: 김일호 :: AWS Summit Seoul 2016
DynamoDB를 이용한 PHP와 Django간 세션 공유 - 강대성 (피플펀드컴퍼니)
게임업계 IT 관리자를 위한 7가지 유용한 팁 - 박선용 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming
Lambda를 활용한 서버없는 아키텍쳐 구현하기 :: 김기완 :: AWS Summit Seoul 2016
웹 이후의 세계 제3장
소셜카지노 초기런칭 및 실험결과 공유
HBase Schema Design - HBase-Con 2012
20131002 AWS Meister re:Generate - DynamoDB (Korean)
Amazon Redshift로 데이터웨어하우스(DW) 구축하기
관계형 데이터베이스의 새로운 패러다임 Amazon Aurora :: 김상필 :: AWS Summit Seoul 2016
Bottled water 요약 설명 20151114
Amazon Aurora Deep Dive (김기완) - AWS DB Day
Amazon Aurora 100% 활용하기
Tutorial olap4j
2014.4.30 프라이머 개발자 모임 - 서버 장애 예방 및 대응 방법 공유
디지털 인문학 데이터베이스 개론
다중성 확보, 시스템 안정화
Compare DynamoDB vs. MongoDB
AWS Lambda 100% 활용하기 :: 김상필 솔루션즈 아키텍트 :: Gaming on AWS 2016
Ad

Similar to 게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming (12)

PDF
Amazon Dynamo DB for Developers (김일호) - AWS DB Day
PPTX
MongoDB 3.0
PDF
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
ODP
DrupalCon Chicago Practical MongoDB and Drupal
PDF
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
KEY
Managing Social Content with MongoDB
PDF
Working with JSON Data in PostgreSQL vs. MongoDB
KEY
Mongodb intro
PDF
Full metal mongo
PPTX
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
PDF
Making sense of your data jug
PPTX
Einführung in MongoDB
Amazon Dynamo DB for Developers (김일호) - AWS DB Day
MongoDB 3.0
Getting Strated with Amazon Dynamo DB (Jim Scharf) - AWS DB Day
DrupalCon Chicago Practical MongoDB and Drupal
Use Performance Insights To Enhance MongoDB Performance - (Manosh Malai - Myd...
Managing Social Content with MongoDB
Working with JSON Data in PostgreSQL vs. MongoDB
Mongodb intro
Full metal mongo
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Making sense of your data jug
Einführung in MongoDB

More from Amazon Web Services Korea (20)

PDF
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
PDF
[D3T1S06] Neptune Analytics with Vector Similarity Search
PDF
[D3T1S03] Amazon DynamoDB design puzzlers
PDF
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
PDF
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
PDF
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
PDF
[D3T1S02] Aurora Limitless Database Introduction
PDF
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
PDF
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 2
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 1
PDF
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
PDF
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
PDF
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
PDF
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
PDF
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
PDF
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
PDF
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
PDF
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
PDF
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
[D3T1S06] Neptune Analytics with Vector Similarity Search
[D3T1S03] Amazon DynamoDB design puzzlers
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
[D3T1S02] Aurora Limitless Database Introduction
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
AWS Modern Infra with Storage Roadshow 2023 - Day 2
AWS Modern Infra with Storage Roadshow 2023 - Day 1
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Electronic commerce courselecture one. Pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
The Rise and Fall of 3GPP – Time for a Sabbatical?
Building Integrated photovoltaic BIPV_UPV.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...

게임을 위한 DynamoDB 사례 및 팁 - 김일호 솔루션즈 아키텍트:: AWS Cloud Track 3 Gaming

  • 1. 게임을 위한 DynamoDB 사례 및 팁 김일호 | Solutions Architect 박성원, Nexon Korea | 파트장
  • 2. Agenda §Tip 1. DynamoDB Index(LSI, GSI) §Tip 2. DynamoDB Scaling §Tip 3. DynamoDB Data Modeling §Scenario based Best Practice §Nexon use-case
  • 4. Local secondary index (LSI) §Alternate range key attribute §Index is local to a hash key (or partition) A1 (hash) A3 (range) A2 (table key) A1 (hash) A2 (range) A3 A4 A5 LSIs A1 (hash) A4 (range) A2 (table key) A3 (projected) Table KEYS_ONLY INCLUDE A3 A1 (hash) A5 (range) A2 (table key) A3 (projected) A4 (projected) ALL 10 GB max per hash key, i.e. LSIs limit the # of ran ge keys!
  • 5. Global secondary index (GSI) §Alternate hash (+range) key §Index is across all table hash keys (partitions) A1 (hash) A2 A3 A4 A5 GSIs A5 (hash) A4 (range) A1 (table key) A3 (projected) Table INCLUDE A3 A4 (hash) A5 (range) A1 (table key) A2 (projected) A3 (projected) ALL A2 (hash) A1 (table key) KEYS_ONLY RCUs/WCUs provisioned se parately for GSIs Online indexing
  • 6. How do GSI updates work? Table Primary ta ble Primary ta ble Primary ta ble Primary ta ble Global Seco ndary Index Client 2. Asynchronous update (in progress) If GSIs don’t have enough write capacity, table writes will be throttled!
  • 7. LSI or GSI? §LSI can be modeled as a GSI §If data size in an item collection > 10 GB, use GSI §If eventual consistency is okay for your scenario, use GSI!
  • 9. Scaling §Throughput § Provision any amount of throughput to a table §Size § Add any number of items to a table § Max item size is 400 KB § LSIs limit the number of range keys due to 10 GB limit §Scaling is achieved through partitioning
  • 10. Throughput §Provisioned at the table level § Write capacity units (WCUs) are measured in 1 KB per second § Read capacity units (RCUs) are measured in 4 KB per second § RCUs measure strictly consistent reads § Eventually consistent reads cost 1/2 of consistent reads §Read and write throughput limits are independent WCURCU
  • 11. Partitioning math Number of Partitions By Capacity (Total RCU / 3000) + (Total WCU / 1000) By Size Total Size / 10 GB Total Partitions CEILING(MAX (Capacity, Size))
  • 15. Getting the most out of DynamoDB throughput “To get the most out of DynamoDB throughput, create tables where the hash key element has a large number of distinct values, and values are requested fairly uniformly, as randomly as possible.” —DynamoDB Developer Guide §Space: access is evenly spread over the key- space §Time: requests arrive evenly spaced in time
  • 16. What causes throttling? § If sustained throughput goes beyond provisioned throughput per partition § Non-uniform workloads § Hot keys/hot partitions § Very large bursts § Mixing hot data with cold data § Use a table per time period § From the example before: § Table created with 5000 RCUs, 500 WCUs § RCUs per partition = 1666.67 § WCUs per partition = 166.67 § If sustained throughput > (1666 RCUs or 166 WCUs) per key or partition, DynamoDB may throttle requests § Solution: Increase provisioned throughput
  • 18. 1:1 relationships or key-values §Use a table or GSI with a hash key §Use GetItem or BatchGetItem API §Example: Given an SSN or license number, get attributes Users Table Hash key Attributes SSN = 123-45-6789 Email = johndoe@nowhere.com, License = TDL25478134 SSN = 987-65-4321 Email = maryfowler@somewhere.com, License = TDL78309234 Users-Email-GSI Hash key Attributes License = TDL78309234 Email = maryfowler@somewhere.com, SSN = 987-65-4321 License = TDL25478134 Email = johndoe@nowhere.com, SSN = 123-45-6789
  • 19. 1:N relationships or parent-children §Use a table or GSI with hash and range key §Use Query API Example: § Given a device, find all readings between epoch X, Y Device-measurements Hash Key Range key Attributes DeviceId = 1 epoch = 5513A97C Temperature = 30, pressure = 90 DeviceId = 1 epoch = 5513A9DB Temperature = 30, pressure = 90
  • 20. N:M relationships §Use a table and GSI with hash and range key elements switched §Use Query API Example: Given a user, find all games. Or given a game, find all users. User-Games-Table Hash Key Range key UserId = bob GameId = Game1 UserId = fred GameId = Game2 UserId = bob GameId = Game3 Game-Users-GSI Hash Key Range key GameId = Game1 UserId = bob GameId = Game2 UserId = fred GameId = Game3 UserId = bob
  • 21. Documents (JSON) § New data types (M, L, BOOL, NULL) introduced to support JSON § Document SDKs § Simple programming model § Conversion to/from JSON § Java, JavaScript, Ruby, .NET § Cannot index (S,N) elements of a JSON object stored in M § Only top-level table attributes can be used in LSIs and GSIs without Streams/Lambda JavaScript DynamoDB string S number N boolean BOOL null NULL array L object M
  • 22. Rich expressions §Projection expression § Query/Get/Scan: ProductReviews.FiveStar[0] §Filter expression § Query/Scan: #VIEWS > :num §Conditional expression § Put/Update/DeleteItem: attribute_not_exists (#pr.FiveStar) §Update expression § UpdateItem: set Replies = Replies + :num
  • 25. Time series tables Events_table_2015_April Event_id (Hash key) Timestamp (range key) Attribute1 …. Attribute N Events_table_2015_March Event_id (Hash key) Timestamp (range key) Attribute1 …. Attribute N Events_table_2015_Feburary Event_id (Hash key) Timestamp (range key) Attribute1 …. Attribute N Events_table_2015_January Event_id (Hash key) Timestamp (range key) Attribute1 …. Attribute N RCUs = 1000 WCUs = 100 RCUs = 10000 WCUs = 10000 RCUs = 100 WCUs = 1 RCUs = 10 WCUs = 1 Current table Older tables Hot dataCold data Don’t mix hot and cold data; archive cold data to Amazon S3
  • 26. Important when: Use a table per time period §Pre-create daily, weekly, monthly tables §Provision required throughput for current table §Writes go to the current table §Turn off (or reduce) throughput for older tables Dealing with time series data
  • 28. Partition 1 2000 RCUs Partition K 2000 RCUs Partition M 2000 RCUs Partition 50 2000 RCU Scaling bottlenecks Product A Product B Gamers ItemShopCatalog Table SELECT Id, Description, ... FROM ItemShopCatalog
  • 30. Partition 1 Partition 2 ItemShopCatalog Table User DynamoDB User Cache popular items SELECT Id, Description, ... FROM ProductCatalog
  • 32. Multiplayer online gaming Query filters vs. composite key indexes
  • 33. GameId Date Host Opponent Status d9bl3 2014-10-02 David Alice DONE 72f49 2014-09-30 Alice Bob PENDING o2pnb 2014-10-08 Bob Carol IN_PROGRESS b932s 2014-10-03 Carol Bob PENDING ef9ca 2014-10-03 David Bob IN_PROGRESS Games Table Multiplayer online game data Hash key
  • 34. Query for incoming game requests §DynamoDB indexes provide hash and range §What about queries for two equalities and a range? SELECT * FROM Game WHERE Opponent='Bob‘ AND Status=‘PENDING' ORDER BY Date DESC (hash) (range) (?)
  • 35. Secondary Index Opponent Date GameId Status Host Alice 2014-10-02 d9bl3 DONE David Carol 2014-10-08 o2pnb IN_PROGRESS Bob Bob 2014-09-30 72f49 PENDING Alice Bob 2014-10-03 b932s PENDING Carol Bob 2014-10-03 ef9ca IN_PROGRESS David Approach 1: Query filter BobHash key Range key
  • 36. Secondary Index Approach 1: query filter Bob Opponent Date GameId Status Host Alice 2014-10-02 d9bl3 DONE David Carol 2014-10-08 o2pnb IN_PROGRESS Bob Bob 2014-09-30 72f49 PENDING Alice Bob 2014-10-03 b932s PENDING Carol Bob 2014-10-03 ef9ca IN_PROGRESS David SELECT * FROM Game WHERE Opponent='Bob' ORDER BY Date DESC FILTER ON Status='PENDING' (filtered out)
  • 37. Needle in a haystack Bob
  • 38. Important when: Use query filter §Send back less data “on the wire” §Simplify application code §Simple SQL-like expressions § AND, OR, NOT, () Your index isn’t entirely selective
  • 39. Approach 2: composite key StatusDate DONE_2014-10-02 IN_PROGRESS_2014-10-08 IN_PROGRESS_2014-10-03 PENDING_2014-09-30 PENDING_2014-10-03 Status DONE IN_PROGRESS IN_PROGRESS PENDING PENDING Date 2014-10-02 2014-10-08 2014-10-03 2014-10-03 2014-09-30 + =
  • 40. Secondary Index Approach 2: composite key Opponent StatusDate GameId Host Alice DONE_2014-10-02 d9bl3 David Carol IN_PROGRESS_2014-10-08 o2pnb Bob Bob IN_PROGRESS_2014-10-03 ef9ca David Bob PENDING_2014-09-30 72f49 Alice Bob PENDING_2014-10-03 b932s Carol Hash key Range key
  • 41. Opponent StatusDate GameId Host Alice DONE_2014-10-02 d9bl3 David Carol IN_PROGRESS_2014-10-08 o2pnb Bob Bob IN_PROGRESS_2014-10-03 ef9ca David Bob PENDING_2014-09-30 72f49 Alice Bob PENDING_2014-10-03 b932s Carol Secondary Index Approach 2: composite key Bob SELECT * FROM Game WHERE Opponent='Bob' AND StatusDate BEGINS_WITH 'PENDING'
  • 42. Needle in a sorted haystack Bob
  • 43. Sparse indexes Id (Hash) User Game Score Date Award 1 Bob G1 1300 2012-12-23 2 Bob G1 1450 2012-12-23 3 Jay G1 1600 2012-12-24 4 Mary G1 2000 2012-10-24 Champ 5 Ryan G2 123 2012-03-10 6 Jones G2 345 2012-03-20 Game-scores-table Award (Hash) Id User Score Champ 4 Mary 2000 Award-GSI Scan sparse hash GSIs
  • 44. Important when: Replace filter with indexes §Concatenate attributes to form useful §secondary index keys §Take advantage of sparse indexes You want to optimize a query as much as possible Status + Date
  • 46. Nexon Korea, 박성원 파트장 넥슨 모바일 게임 관련 데이터베이스 업무를 담당하고 있습니다.
  • 47. DDB 사용현황 §HIT 메인 게임DB • 27 Tables • Various Alarms • Flexible Dashboards
  • 48. DDB, 이런 분에게 추천합니다. §Capacity 산정 §Monitoring §백업 및 복원 §Tips https://i.ytimg.com/vi/C6U2M7ZkZI8/maxresdefault.jpg
  • 49. Capacity 산정 § 서비스 전 읽기/쓰기에 대한 패턴 테스트를 꼭 수행하세요. § 모든 패턴이 읽혀지진 않지만, 병목의 중심이 되는 대략적인 내용은 파악할 수 있습니다. § 동시 사용자 증가 속도를 꼭 염두에 두셔야 합니다. 대응하려는 순간 이미 서비스 불가일 수 있습니다. Ø 2분 안에 800,000 증가 Ø 초당 RCUs 변환 시 13,000 증가 시간 읽 기 호 출 수
  • 50. Capacity 변경 §웹콘솔, AWS앱, CLI 등으로 쉽게 Capacity 변경이 가능합니다. §다만, 즉시 적용은 되지 않습니다. AWS에도 작업 시간을 주세요. §대량의 RCUs, WCUs 변경이 필요한 경우는 미리 준비하는 것이 좋습니다.
  • 51. Capacity 모니터링 §Cloud Watch 를 활용하세요. §대시보드 및 알람 기능이 매우 유용합니다. §초 단위 데이터까지 보기엔 어렵습니다. (1분 단위 Sum)
  • 52. 백업 및 복원 § Export / Import 개념입니다. § Data Pipeline 을 사용하세요. § CLI 에 친숙해 지세요. 반복적인 작업을 쉽게 구현할 수 있습니다.
  • 53. 소소한 Tip §Read / Write 캐시 레이어 도입을 고려하세요. • Retry 시 지수 백오프 알고리즘을 도입하세요. • Data 용량계획을 고려하세요. http://cfile30.uf.tistory.com/image/221DF544538C11D62866E9
  • 54. DDB 를 사용해보니… §전통적인 RDB와 비교하여 손댈 것이 거의 없습니다. §AWS Document 에 근거하여 개발하셔야 합니다. §운영 시 Cloud Watch 및 CLI 가 많은 도움이 됩니다.