More Related Content Similar to 서버리스 기반 데이터베이스 모델링 및 운영 노하우 알아보기 - 변규현 SW 엔지니어, 당근마켓 / 김선형 CTO, 티클 :: AWS Summit Seoul 2021 (20) More from Amazon Web Services Korea (20) 서버리스 기반 데이터베이스 모델링 및 운영 노하우 알아보기 - 변규현 SW 엔지니어, 당근마켓 / 김선형 CTO, 티클 :: AWS Summit Seoul 20211. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
K O R E A | M A Y 1 1 - 1 2 , 2 0 2 1
2. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
서버리스 기반 데이터베이스 모델링 및
운영 노하우 알아보기
변규현
SW 엔지니어
당근마켓
김선형
CTO
티클
3. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon RDS Proxy와Aurora Serverless
활용 방법
4. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• Serverless가 무엇일까요?
• Amazon RDS Proxy
• Amazon Aurora Serverless V1
• Amazon Aurora Serverless V2
오늘 다룰 내용
5. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• - 클라우드 공급자가 필요에 따라 리소스를 할당하는 컴퓨팅 실행 모델
• - 사용자을 대신하여 클라우드 공급자가 서버를 관리함
• - 서버리스 컴퓨팅은 휘발성 메모리에 리소스를 보유하지 않음
• - 컴퓨팅은 결과가 스토리지에 유지되는 짧은 순간에 수행됨
• - 앱을 사용하지 않을 때는 앱에 할당 된 컴퓨팅 리소스가 없음
• - 가격은 애플리케이션에서 사용하는 실제 리소스 양을 기준으로 함
• - 서버리스 애플리케이션 개발자는 컨테이너, VM 또는 물리적 서버의 용량 계획, 구성,
관리, 유지 관리, 운영 또는 확장에 관심이 없어도 됨.
• - 서버리스 컴퓨팅은 코드를 프로덕션에 배포하는 프로세스를 단순화 함
서버리스(Serverless)란?
https://en.wikipedia.org/wiki/Serverless_computing
https://aws.amazon.com/ko/serverless/
6. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS 서버리스 서비스
AWS Lambda AWS Fargate
Amazon EventBridge AWS Step Functions Amazon Simple Queue
Service (Amazon SQS)
Amazon Simple
Notification Service
(Amazon SNS)
AWS AppSync Amazon API Gateway
Amazon Simple
Storage Service
(Amazon S3)
Amazon DynamoDB Amazon RDS Proxy Amazon Aurora
Serverless
7. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon RDS의 완전 관리형 고가용성 데이터베이스 프록시
1) 데이터베이스 연결을 풀링하고 공유하여 확장성을 개선
2) 데이터베이스 장애 조치 시간을 최대 66 %까지 줄이고 장애 조치 중에
애플리케이션 연결을 보존하여 가용성을 향상시킴
3) 선택적으로 데이터베이스에 AWS IAM 인증을 적용하고 AWS Secrets Manager에
자격 증명을 안전하게 저장하여 보안을 개선할 수 있음
Amazon RDS Proxy
8. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
- 예측할 수 없는 워크로드가 있는 경우
- 데이터베이스 연결을 자주 열고 닫는 경우
- 연결을 유지하지만 유휴 상태로 유지하는 경우
- 일시적인 오류를 통해 가용성이 필요한 경우
- 향상된 보안 및 중앙 집중식 자격 증명 관리
RDS Proxy Use cases
9. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
- Amazon Aurora에 대한 On-demand autoscaling 지원
- 요구 사항에 따라 컴퓨팅 용량을 확장 및 축소하는 DB 클러스터
- Aurora Serverless v1은 드물거나 간헐적이거나 예측할 수 없는 워크로드에 대해
비교적 간단하고 비용 효율적인 옵션을 제공함
- 자동으로 시작되고 사용량에 맞게 컴퓨팅 용량을 확장하며 사용하지 않을 때 종료됨
- 활성 상태일 때 데이터베이스가 소비하는 데이터베이스 스토리지, 데이터베이스
용량 및 I/O에 대한 요금을 지불
Amazon Aurora Serverless V1
10. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
- 자주 사용하지 않는 경우
- 처음 릴리즈하는 서비스
- 가변적인 워크로드
- 예측할 수 없는 워크로드
- 개발 및 테스트 데이터베이스
Aurora Serverless V1 Use cases
11. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
- Aurora cloning, global databases, multi-master, Replicas
- (IAM) database authentication, Backtracking in Aurora
- Database activity streams, Performance Insights
- Aurora Serverless v1 스냅샷을 Amazon S3 버킷으로 내보내기
- Lambda 함수를 호출할 수 없음
- Aurora PostgreSQL 쿼리 계획 관리 (apg_plan_management)는 지원하지 않음
- DB 클러스터에 대한 연결은 하루 이상 열려 있으면 자동으로 닫힘
...
Aurora Serverless V1 Limitations
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html#aurora-serverless.use-cases
12. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
More about Aurora Serverless V1
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.how-it-works.html#aurora-serverless.architecture
13. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
- 즉시 확장 가능한 서버리스 DB 클러스터를 지원하도록 처음부터 설계함
- 요청의 급격한 증가를 충족 할 수 있을만큼 가볍게 설계함(Instant autoscaling)
- DB 클러스터가 임계 값에 도달 할 때마다 ACU를 두 배로 확장하는 Aurora
Serverless v1과 달리 Aurora Serverless v2는 ACU를 점진적으로 늘릴 수 있음
Aurora Serverless V2(Preview)
https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless-2.how-it-works.html
14. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
마무리 – 서버리스 데이터베이스 선택 확대
Aurora
Serverless
DynamoDB DocumentDB Timestream
Neptune QLDB Keyspaces
RDB에서도
서버리스 제공
요구 사항별
DB 선택 옵션 제공
클라우드
네이티브 설계
1 2 3
15. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon DynamoDB Single Table
Design기반 서비스 구현하기
16. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
17. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• 30만명이 사용 중인 금융서비스 “티클"
• DB – Only DynamoDB
• Table – Only 1 table
이래서 준비했습니다
18. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Single Table Design
19. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Single Table Design
20. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
1. 기획안으로부터 Access Pattern 도출
2. 기존 Index, Model을 고려해 스키마 수정사항 정리
3. 스키마 미팅을 통한 엔지니어 피드백
모델링 과정
21. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
• Query 성능 튜닝에 고민을 선제적으로 진행
• 비즈니스 로직과 Query를 분리하여 사고
• 별도의 DBA 없이 모두가 DB에 대한 이해도 증진
• 스키마 미팅을 통해 다른 엔지니어의 작업 파악 가능
장점
22. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
실제 모델링 사례
23. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
카드 및 카드 이용 내역 모델링
1. Access pattern 정의
24. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
카드 및 카드 이용 내역 모델링
1. Access pattern 정의
• 사용자가 연동한 카드 불러오기
• 사용자의 카드 이용 내역 불러오기
• 사용자의 카드별 이용 내역 불러오기
25. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
카드 및 카드 이용 내역 모델링
2. Access pattern에 기반하여 모델링 도출
• 사용자가 연동한 카드 불러오기
PK=$userId and begins_with(SK=”card#”)
• 사용자의 카드 이용 내역 불러오기
PK=$userId and begins_with(SK=”transaction#”)
• 사용자의 카드별 이용 내역 불러오기
PK=$userId and begins_with(SK=”transaction#hyundai”)
26. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
카드 및 카드 이용 내역 모델링
3. 모델링 과정에서 고려한 내용
• 적절한 partitioning을 위해 Partition Key로 userId를 사용
• SK에 #을 이용하여 모델 이름 및 데이터 분리
• Transaction 모델 SK에 시간 데이터를 추가하여 특정 time range의
데이터를 Query 가능
• 불변의 정보인 cardVendor을 두 모델에 중복으로 기입
27. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
해외주식 데이터 모델링
1. Access pattern 정의
28. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
해외주식 데이터 모델링
1. Access pattern 정의
• 모든 해외주식 기본 정보 (종목 한글 이름, 종록 로고 등) 가져오기
• 해외주식 기본 정보 및 상세 정보 (관련 뉴스, 차트 정보 등) 가져오기
• 해외주식 뉴스 데이터 가져오기
29. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
해외주식 데이터 모델링
2. Access pattern에 기반하여 모델링 도출
• 모든 해외주식 기본 정보 (종목 한글 이름, 종록 로고 등) 가져오기
GSI(SK-PK-INDEX) SK=“stockInfo”
• 해외주식 1개 기본 정보 및 상세 정보 (관련 뉴스, 차트 정보 등) 가져오기
PK=$stockISIN
• 해외주식 뉴스 데이터 가져오기
PK=$stockISIN and begins_with(SK=”news#”)
30. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
해외주식 데이터 모델링
3. 모델링 과정에서 고려한 내용
• GSI SK-PK-INDEX를 정의하여 모든 종목의 기본 정보를 쿼리 가능
• PK stockISIN에 모든 종목에 대한 정보를 저장하여 한번에 쿼리 가능
• NoSQL에서 Access pattern에 기초한 관계형 모델링 구현
31. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
여러분의 소중한 피드백을 기다립니다.
강연 종료 후, 강연 평가에 참여해 주세요!
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
32. © 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.
감사합니다
© 2021, Amazon Web Services, Inc. or its affiliates. All rights reserved.