SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
분산 트랙젝션
유승기, Software Engineer, MongoDB
큰 힘에는 책임이 따른다.
여러분들이 어떤 생각을
가지고 계시는 지 알고 있습니다.
하지만, 사실은…
MongoDB 는 ACID 를 준수 합니다.
(물론, 여러 샤드에서도 말이죠.)
트랜잭션을 지원함으로써 개발이 쉬워집니다.
트랜잭션 상태에 대해 개발자가 걱정할 필요가 없음
단일 명령문이 실패할 경우 Rollback/Abort 가 자동 처리
읽기와 쓰기의 특정 시점에서 일관성 유지
def insertDocuments(s):
s.client.db.col.insert_one({'abc': 1}, session=s)
s.client.db.col.insert_one({'xyz': 999}, session=s)
with client.start_session() as s:
s.with_transaction(insertDocuments);
New API MongoDB 4.2!
New in MongoDB 4.2 - Cross Shard Transactions
트랜잭션 보증
Multi- Collection
Database
Statement
Document
Shard
All or nothing execution
TXN
Application
MongoDB
Uncommitted Writes
{ Document 1 } { Document 2 }
{ Document 3 }
Committed Writes
Snapshot Isolation
100 101 102 103 104 105 106 107 108 109 110 111
Snapshot
102
Snapshot
108
Read Your Own Writes
Operation
Read
TXN
{_id: “OWNER12345”,
name: { first: “Aly”,
last: “Cabral”},
accountType: “Paid”,
pets: [ { type: “Dog”,
name: “Lady”}],
contact: { phoneNumber: 8008675309},
Address: { city: “New York”,
street: “94th”,
zipecode: 10025}}
Uncommitted Writes
street: “92nd”
Address.street = 94th
Address.street = 92nd
트랜잭션 가이드라인
기존 JSON 기반으로 한 모델링은 여전히 유효
트랜잭션은 가장 일반적으로 많이 쓰는 작업이 아니어야 함
세션을 통해 모든 명령문을 실행하여야함
트랜잭션은 항상 중단 가능하므로 재시도 로직을 구현 하여야함
불필요한 스냅샷을 열어 두면 안됨
쓰기 작업 충돌을 처리하기 위해선 반드시 같은 Doucment 에 대해 쓰기 작업을 수행하고
있어야 함
DDL 은 현재 지원되지 않음
분산 트랜잭션의 작동 방식
Majority Writes
Majority Write 는 어떤 기능 입니까?
ReplicaSet Cluster에 데이터가 견고하게 저장 되는 기능을 말합니다.
No Abiters
Participant (참가자)
특정 트랜잭션을 대신하여 작업을 실행하는 임의의 샤드
Coordinator
특정 트랜잭션에 대해 여러 샤드에 걸쳐 커밋을 조정하는
책임이 있는 단일 샤드
P
S
S
S
P
S
Query Router
Insert {_id : “abc”}Insert {_id : “xyz”}
Coordinator!
Commit transaction
모든 ReplicaSet Node 에서 커밋이 발생
트랜잭션이 없는 세상을 상상해보십시오.
“ 자체적으로 트랜잭션을 구현해서
실행할 때와 비교할 경우 MongoDB
트랜잭션을 실행할때 2배 이상 성능이
향상 되었습니다.”
분산 환경에서 성능 향상을 내기 위해서는
데이터를 한곳에 모아서
분산 환경에서 성능 향상을 내기 위해서는
하나의 샤드에 쓰기를 수행
Read Isolation
READ CONCERN = READ ISOLATION
Options: LOCAL, MAJORITY,
SNAPSHOT, LINEARIZABLE
흥미로운 점: ReadConcern Majority는
조회 결과를 가지고 오기 위해
노드간에 조정(Cooridnate) 를 할 필요가 없다.
Read
Concern:
Snapshot
P
S
S
P
S
S
P
S
S
time: 102
Majority
or
Local
time: 102 time: 110 time: 104
스냅샷 격리에는 많은 자원이 필요합니다.
모든 샤드는 시간에 대해 조정 작업이 필요함
트랜잭션이 발생하는 시간동안 동일한 스냅샷을
사용
Locking
쓰기
트랜잭션 내부
쓰기 작업은 Document 에 대핸 변경을 시도할때 잠금 획득을 시도한다.
잠금 획득을 성공 못했을 경우 해당 작업은 취소되며 롤백 된다.
트랜잭션 외부
쓰기 작업이 잠금 획득을 시도 하는데 실패하면 exponential back off 를 사용하여 다시 시도 한다.
읽기
쓰기 작업만 잠금 획득을 시도한다.
읽기 전용 트랜잭션이 수행되는 동안, 다른 트랜잭션이 Document 수정을 하게 되면 Stale
Read 가 가능해짐
Document 변경에 대한 트랜잭션이 실패하려면 동일한 Document 수정하고 있어야 한다.
4.2 에 새로 추가된 기능
16MB 이상의 트랜잭션 지원
MongoDB 4.0
{ <statement 1>,
<statement 2>,
<statement 3>,
<statement 4>}
MongoDB 4.2
{<statement 1>},
{<statement 2>},
{<statement 3>},
{<statement 4>}
그렇다고 해서 대량의 트랜잭션이
무한정 가능한 것은 아닙니다.
WiredTiger 는 스냅샷 이후에도 여전히 이력을 유지해야 합니다.
트랜잭션은 트랜잭션 수행시간 동안 동일한 스냅샷을 생성합니다.
트랜잭션은 60초 이후에 자동으로 중단 됩니다. – 변경가능
transactionLifetimeLimitSeconds
변경 가능한 샤드키 값
계층화된 스토리지: 저비용 스토리지 샤드에 오래된 Document 를 저장
글로벌-재분산 : Document 를 다른 지역으로 옮김
MongoDB 4.2 드라이버 사용
단일 샤드를 대상으로 하는 트랜잭션은 여러 샤드에 걸친 트랜잭션 보다
빠르게 수행됨
Best practice: 하나의 트랜잭션에 1,000 이하의 Document 를 수정
Arbiter 없음
청크 마이그레이션은 트랜잭션이 일어나는 동안 중지되어 트랜잭션이
끝난 이후 실행됨
Parting Wisdom
무료 ▪ 온라인 ▪ 9의 챕터로 구성
지금 등록 하십시오! -
https://university.mongodb.com/courses/M042/about
감사합니다!
분산 트랜잭션
[유승기]
https://www.research.net/r/DistributedTransactionsSeoul

Contenu connexe

Tendances

mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교Woo Yeong Choi
 
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, ClusterJi-Woong Choi
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Web Services Korea
 
Massive service basic
Massive service basicMassive service basic
Massive service basicDaeMyung Kang
 
Data Processing behind LINE Game Platform
Data Processing behind LINE Game PlatformData Processing behind LINE Game Platform
Data Processing behind LINE Game PlatformLINE Corporation
 
Maxscale_메뉴얼
Maxscale_메뉴얼Maxscale_메뉴얼
Maxscale_메뉴얼NeoClova
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?Mydbops
 
redis 소개자료 - 네오클로바
redis 소개자료 - 네오클로바redis 소개자료 - 네오클로바
redis 소개자료 - 네오클로바NeoClova
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQLI Goo Lee
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestI Goo Lee
 
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDBNAVER D2
 
MySQL GTID 시작하기
MySQL GTID 시작하기MySQL GTID 시작하기
MySQL GTID 시작하기I Goo Lee
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]MongoDB
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKYoungHeon (Roy) Kim
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우jieunsys
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바NeoClova
 
MongoDB 모바일 게임 개발에 사용
MongoDB 모바일 게임 개발에 사용MongoDB 모바일 게임 개발에 사용
MongoDB 모바일 게임 개발에 사용흥배 최
 
Postgresql Database Administration- Day3
Postgresql Database Administration- Day3Postgresql Database Administration- Day3
Postgresql Database Administration- Day3PoguttuezhiniVP
 
MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개rockplace
 

Tendances (20)

mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교mongodb와 mysql의 CRUD 연산의 성능 비교
mongodb와 mysql의 CRUD 연산의 성능 비교
 
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster
[오픈소스컨설팅]Day #2 MySQL Tuning, Replication, Cluster
 
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB DayAmazon Redshift의 이해와 활용 (김용우) - AWS DB Day
Amazon Redshift의 이해와 활용 (김용우) - AWS DB Day
 
Massive service basic
Massive service basicMassive service basic
Massive service basic
 
Data Processing behind LINE Game Platform
Data Processing behind LINE Game PlatformData Processing behind LINE Game Platform
Data Processing behind LINE Game Platform
 
Maxscale_메뉴얼
Maxscale_메뉴얼Maxscale_메뉴얼
Maxscale_메뉴얼
 
What is new in MariaDB 10.6?
What is new in MariaDB 10.6?What is new in MariaDB 10.6?
What is new in MariaDB 10.6?
 
redis 소개자료 - 네오클로바
redis 소개자료 - 네오클로바redis 소개자료 - 네오클로바
redis 소개자료 - 네오클로바
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQL
 
MySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software TestMySQL/MariaDB Proxy Software Test
MySQL/MariaDB Proxy Software Test
 
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
 
MySQL GTID 시작하기
MySQL GTID 시작하기MySQL GTID 시작하기
MySQL GTID 시작하기
 
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
Naver속도의, 속도에 의한, 속도를 위한 몽고DB (네이버 컨텐츠검색과 몽고DB) [Naver]
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우
 
MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바MariaDB 마이그레이션 - 네오클로바
MariaDB 마이그레이션 - 네오클로바
 
MongoDB 모바일 게임 개발에 사용
MongoDB 모바일 게임 개발에 사용MongoDB 모바일 게임 개발에 사용
MongoDB 모바일 게임 개발에 사용
 
Redis
RedisRedis
Redis
 
Postgresql Database Administration- Day3
Postgresql Database Administration- Day3Postgresql Database Administration- Day3
Postgresql Database Administration- Day3
 
MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개MySQL InnoDB Cluster 소개
MySQL InnoDB Cluster 소개
 

Similaire à 분산 트랜잭션 - 큰힘에는 큰 책임이 따른다 [MongoDB]

Hadoop distributed file system rev3
Hadoop distributed file system rev3Hadoop distributed file system rev3
Hadoop distributed file system rev3Sung-jae Park
 
Multitasking on DB and Django
Multitasking on DB and DjangoMultitasking on DB and Django
Multitasking on DB and DjangoSeokhwanMoon
 
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019devCAT Studio, NEXON
 
[스마트스터디]MongoDB 의 역습
[스마트스터디]MongoDB 의 역습[스마트스터디]MongoDB 의 역습
[스마트스터디]MongoDB 의 역습smartstudy_official
 
Redis Overview
Redis OverviewRedis Overview
Redis Overviewkalzas
 
FIFA 온라인 3의 MongoDB 사용기
FIFA 온라인 3의 MongoDB 사용기FIFA 온라인 3의 MongoDB 사용기
FIFA 온라인 3의 MongoDB 사용기Jongwon Kim
 
[246] foursquare데이터라이프사이클 설현준
[246] foursquare데이터라이프사이클 설현준[246] foursquare데이터라이프사이클 설현준
[246] foursquare데이터라이프사이클 설현준NAVER D2
 
AWS 9월 웨비나 | Amazon Aurora Deep Dive
AWS 9월 웨비나 | Amazon Aurora Deep DiveAWS 9월 웨비나 | Amazon Aurora Deep Dive
AWS 9월 웨비나 | Amazon Aurora Deep DiveAmazon Web Services Korea
 
NoSQL 간단한 소개
NoSQL 간단한 소개NoSQL 간단한 소개
NoSQL 간단한 소개Wonchang Song
 
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...hoondong kim
 
NET 최선단 기술에 의한 고성능 웹 애플리케이션
NET 최선단 기술에 의한 고성능 웹 애플리케이션NET 최선단 기술에 의한 고성능 웹 애플리케이션
NET 최선단 기술에 의한 고성능 웹 애플리케이션흥배 최
 
Mongodb2.2와 2.4의 신 기능 소개
Mongodb2.2와 2.4의 신 기능 소개Mongodb2.2와 2.4의 신 기능 소개
Mongodb2.2와 2.4의 신 기능 소개흥배 최
 
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013devCAT Studio, NEXON
 
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석smartstudy_official
 
Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Daum DNA
 
Node.js + Websocket 삽질기
Node.js + Websocket 삽질기Node.js + Websocket 삽질기
Node.js + Websocket 삽질기Paprikhan
 
서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드KwangSeob Jeong
 
The MongoDB Strikes Back / MongoDB 의 역습
The MongoDB Strikes Back / MongoDB 의 역습The MongoDB Strikes Back / MongoDB 의 역습
The MongoDB Strikes Back / MongoDB 의 역습Hyun-woo Park
 
BigData Overview
BigData OverviewBigData Overview
BigData OverviewHoryun Lee
 

Similaire à 분산 트랜잭션 - 큰힘에는 큰 책임이 따른다 [MongoDB] (20)

Hadoop distributed file system rev3
Hadoop distributed file system rev3Hadoop distributed file system rev3
Hadoop distributed file system rev3
 
Multitasking on DB and Django
Multitasking on DB and DjangoMultitasking on DB and Django
Multitasking on DB and Django
 
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
홍성우, 게임 서버의 목차 - 시작부터 출시까지, NDC2019
 
[스마트스터디]MongoDB 의 역습
[스마트스터디]MongoDB 의 역습[스마트스터디]MongoDB 의 역습
[스마트스터디]MongoDB 의 역습
 
Redis Overview
Redis OverviewRedis Overview
Redis Overview
 
FIFA 온라인 3의 MongoDB 사용기
FIFA 온라인 3의 MongoDB 사용기FIFA 온라인 3의 MongoDB 사용기
FIFA 온라인 3의 MongoDB 사용기
 
[246] foursquare데이터라이프사이클 설현준
[246] foursquare데이터라이프사이클 설현준[246] foursquare데이터라이프사이클 설현준
[246] foursquare데이터라이프사이클 설현준
 
AWS 9월 웨비나 | Amazon Aurora Deep Dive
AWS 9월 웨비나 | Amazon Aurora Deep DiveAWS 9월 웨비나 | Amazon Aurora Deep Dive
AWS 9월 웨비나 | Amazon Aurora Deep Dive
 
NoSQL 간단한 소개
NoSQL 간단한 소개NoSQL 간단한 소개
NoSQL 간단한 소개
 
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
Auto Scalable 한 Deep Learning Production 을 위한 AI Serving Infra 구성 및 AI DevOps...
 
NET 최선단 기술에 의한 고성능 웹 애플리케이션
NET 최선단 기술에 의한 고성능 웹 애플리케이션NET 최선단 기술에 의한 고성능 웹 애플리케이션
NET 최선단 기술에 의한 고성능 웹 애플리케이션
 
Mongodb2.2와 2.4의 신 기능 소개
Mongodb2.2와 2.4의 신 기능 소개Mongodb2.2와 2.4의 신 기능 소개
Mongodb2.2와 2.4의 신 기능 소개
 
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
 
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
[스마트스터디]모바일 애플리케이션 서비스에서의 로그 수집과 분석
 
Clojure Chapter.6
Clojure Chapter.6Clojure Chapter.6
Clojure Chapter.6
 
Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012Cassandra 멘붕기 | Devon 2012
Cassandra 멘붕기 | Devon 2012
 
Node.js + Websocket 삽질기
Node.js + Websocket 삽질기Node.js + Websocket 삽질기
Node.js + Websocket 삽질기
 
서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드서버 아키텍처 이해를 위한 프로세스와 쓰레드
서버 아키텍처 이해를 위한 프로세스와 쓰레드
 
The MongoDB Strikes Back / MongoDB 의 역습
The MongoDB Strikes Back / MongoDB 의 역습The MongoDB Strikes Back / MongoDB 의 역습
The MongoDB Strikes Back / MongoDB 의 역습
 
BigData Overview
BigData OverviewBigData Overview
BigData Overview
 

Plus de MongoDB

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump StartMongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB
 

Plus de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

분산 트랜잭션 - 큰힘에는 큰 책임이 따른다 [MongoDB]

  • 1. 분산 트랙젝션 유승기, Software Engineer, MongoDB 큰 힘에는 책임이 따른다.
  • 2. 여러분들이 어떤 생각을 가지고 계시는 지 알고 있습니다.
  • 3. 하지만, 사실은… MongoDB 는 ACID 를 준수 합니다. (물론, 여러 샤드에서도 말이죠.)
  • 4. 트랜잭션을 지원함으로써 개발이 쉬워집니다. 트랜잭션 상태에 대해 개발자가 걱정할 필요가 없음 단일 명령문이 실패할 경우 Rollback/Abort 가 자동 처리 읽기와 쓰기의 특정 시점에서 일관성 유지
  • 5. def insertDocuments(s): s.client.db.col.insert_one({'abc': 1}, session=s) s.client.db.col.insert_one({'xyz': 999}, session=s) with client.start_session() as s: s.with_transaction(insertDocuments); New API MongoDB 4.2! New in MongoDB 4.2 - Cross Shard Transactions
  • 8. All or nothing execution TXN Application MongoDB Uncommitted Writes { Document 1 } { Document 2 } { Document 3 } Committed Writes
  • 9. Snapshot Isolation 100 101 102 103 104 105 106 107 108 109 110 111 Snapshot 102 Snapshot 108
  • 10. Read Your Own Writes Operation Read TXN {_id: “OWNER12345”, name: { first: “Aly”, last: “Cabral”}, accountType: “Paid”, pets: [ { type: “Dog”, name: “Lady”}], contact: { phoneNumber: 8008675309}, Address: { city: “New York”, street: “94th”, zipecode: 10025}} Uncommitted Writes street: “92nd” Address.street = 94th Address.street = 92nd
  • 12. 기존 JSON 기반으로 한 모델링은 여전히 유효 트랜잭션은 가장 일반적으로 많이 쓰는 작업이 아니어야 함 세션을 통해 모든 명령문을 실행하여야함 트랜잭션은 항상 중단 가능하므로 재시도 로직을 구현 하여야함 불필요한 스냅샷을 열어 두면 안됨 쓰기 작업 충돌을 처리하기 위해선 반드시 같은 Doucment 에 대해 쓰기 작업을 수행하고 있어야 함 DDL 은 현재 지원되지 않음
  • 14. Majority Writes Majority Write 는 어떤 기능 입니까? ReplicaSet Cluster에 데이터가 견고하게 저장 되는 기능을 말합니다. No Abiters
  • 15. Participant (참가자) 특정 트랜잭션을 대신하여 작업을 실행하는 임의의 샤드 Coordinator 특정 트랜잭션에 대해 여러 샤드에 걸쳐 커밋을 조정하는 책임이 있는 단일 샤드
  • 16. P S S S P S Query Router Insert {_id : “abc”}Insert {_id : “xyz”} Coordinator! Commit transaction 모든 ReplicaSet Node 에서 커밋이 발생
  • 17. 트랜잭션이 없는 세상을 상상해보십시오. “ 자체적으로 트랜잭션을 구현해서 실행할 때와 비교할 경우 MongoDB 트랜잭션을 실행할때 2배 이상 성능이 향상 되었습니다.”
  • 18. 분산 환경에서 성능 향상을 내기 위해서는 데이터를 한곳에 모아서
  • 19. 분산 환경에서 성능 향상을 내기 위해서는 하나의 샤드에 쓰기를 수행
  • 21. READ CONCERN = READ ISOLATION Options: LOCAL, MAJORITY, SNAPSHOT, LINEARIZABLE 흥미로운 점: ReadConcern Majority는 조회 결과를 가지고 오기 위해 노드간에 조정(Cooridnate) 를 할 필요가 없다.
  • 23. 스냅샷 격리에는 많은 자원이 필요합니다. 모든 샤드는 시간에 대해 조정 작업이 필요함 트랜잭션이 발생하는 시간동안 동일한 스냅샷을 사용
  • 25. 쓰기 트랜잭션 내부 쓰기 작업은 Document 에 대핸 변경을 시도할때 잠금 획득을 시도한다. 잠금 획득을 성공 못했을 경우 해당 작업은 취소되며 롤백 된다. 트랜잭션 외부 쓰기 작업이 잠금 획득을 시도 하는데 실패하면 exponential back off 를 사용하여 다시 시도 한다.
  • 26. 읽기 쓰기 작업만 잠금 획득을 시도한다. 읽기 전용 트랜잭션이 수행되는 동안, 다른 트랜잭션이 Document 수정을 하게 되면 Stale Read 가 가능해짐 Document 변경에 대한 트랜잭션이 실패하려면 동일한 Document 수정하고 있어야 한다.
  • 27. 4.2 에 새로 추가된 기능
  • 28. 16MB 이상의 트랜잭션 지원 MongoDB 4.0 { <statement 1>, <statement 2>, <statement 3>, <statement 4>} MongoDB 4.2 {<statement 1>}, {<statement 2>}, {<statement 3>}, {<statement 4>}
  • 29. 그렇다고 해서 대량의 트랜잭션이 무한정 가능한 것은 아닙니다. WiredTiger 는 스냅샷 이후에도 여전히 이력을 유지해야 합니다. 트랜잭션은 트랜잭션 수행시간 동안 동일한 스냅샷을 생성합니다. 트랜잭션은 60초 이후에 자동으로 중단 됩니다. – 변경가능 transactionLifetimeLimitSeconds
  • 30. 변경 가능한 샤드키 값 계층화된 스토리지: 저비용 스토리지 샤드에 오래된 Document 를 저장 글로벌-재분산 : Document 를 다른 지역으로 옮김
  • 31. MongoDB 4.2 드라이버 사용 단일 샤드를 대상으로 하는 트랜잭션은 여러 샤드에 걸친 트랜잭션 보다 빠르게 수행됨 Best practice: 하나의 트랜잭션에 1,000 이하의 Document 를 수정 Arbiter 없음 청크 마이그레이션은 트랜잭션이 일어나는 동안 중지되어 트랜잭션이 끝난 이후 실행됨 Parting Wisdom
  • 32. 무료 ▪ 온라인 ▪ 9의 챕터로 구성 지금 등록 하십시오! - https://university.mongodb.com/courses/M042/about