SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
MONGO DB 잡학상식

    MongoDB 한국 사용자 그룹
    charsyam@naver.com
NoSQL의 종류
NoSQL의 종류
Key-Value Store
Column-Oriented Store
Document-Orient Store
NoSQL의 종류
Key-Value Store
Column-Oriented Store
Document-Orient Store
               MongoDB
MongoDB 의 특징
MongoDB의 주요 특징
Document-Oriented
Full Index Support
Querying
MongoDB의 주요 특징
Document-Oriented
Full Index Support
Querying
Easy To Use
Replication
Replication
Master/Slave
장애시 Master가 자동으로 선출되지
않는다.
Replica Set
Automated FailOver
Data Redundancy
Read Scaling(Low Consistency)
Maintenance
Disaster Recovery
Replica Set
OpLog
Write Operation 마다 증가.
(insert/update/delete/index/etc)
Size 가 고정되어 있다.(Collection)
FailOver, Replication 의 핵심
OpTime
class OpTime {
       unsigned i;
       unsigned secs;
}
Idempotent
INC A + 1  이런 형태가 아니라

SET A = 2  이런 형태
HeartBeat
Primary
 - 자신을 포함한 절반 이상의 노드가
응답하지 않으면 Secondary 가 된
다
HeartBeat
Secondary
 - Primary가 응답이 없으면,
Voting을 요청한다.
Primary
• Master
• Only 1 server in a time
Secondary
• Can be thought of as a
  slave in the cluster;
  varies over time
RECOVERING
• getting back in sync
  before entering Secondary
  mode.
Standard
• Primary 가 될 수 있는 노드
Passive
• Replica Set 에는 참여하지만
  Primary가 될 수 없는 노드
• Priority가 0인 노드들
Arbiter
• Replica Set에는 참여하지 않
  고 투표만을 위한 노드, 데이터는
  전달 받지 않는다.
Replication Steps
    Primary              Secondary
  Call Write Operation   Tailing Primary OpLog


    Apply Database           Write OpLog


     Write OpLog            Apply Database
General View
Strong Consistency
             Write
                     Primary
    Driver

             Read

                     Secondary

                     Secondary
Eventual Consistency
             Write
                     Primary
    Driver


             Read    Secondary

             Read    Secondary
FailOver
Automated Leader Election
                      Primary
     Driver

              Write
              Read    Primary

              Read    Secondary
Recovery

              Read    Secondary
     Driver


              Write   Primary

              Read    Secondary
Recovery
If OpLog Size can save 20H
                                  Die 1 Hour
                      Primary
     Driver

              Write
              Read    Primary

              Read    Secondary
Start Replication
                                  Replication
              Read    Secondary
     Driver


              Write   Primary

              Read    Secondary
If Downtime is 21 Hour
                                  Die 21 Hour
                      Primary
     Driver

              Write
              Read    Primary

              Read    Secondary
Start Replication
                                  Need Full Resync
                        Stale
     Driver


              Write   Primary

              Read    Secondary
Voting
Triggering an Election
• 하나의 노드에서 Primary 가 연결이 안
  될때.(단 해당노드는 Arbiter가 아니어
  야 함. Heartbeat(timeout:20))
• 해당 노드의 priority 가 다른 노드보다
  크거나 같을 경우.
Picking Primary
1. get maxLocalOpOrdinal from each server.
2. if a majority of servers are not up (from this
   server's POV), remain in Secondary mode and
   stop.
3. if the last op time seems very old, stop and
   await human intervention.
4. else, using a consensus protocol, pick the server
   with the highest maxLocalOpOrdinal as the
   Primary.
Consensus Vote
과반 수 이상의 득표가 있어야 선출
Source Flows
   repl.cpp             repl/rs.cpp
     startReplication       startThreads

                        repl/manager.cpp
   repl/rs.cpp
                        msgCheckNewState
       startRepSets


   repl/rs.cpp
              _go
TIPS
1. 64bit OS를 사용하라.
MongoDB는 메모리를 많이 사용해야
한다.(MemoryMapped File)
32bit 에서는 2.5GB 짜리 DB파일
만 생성 가능
2. 많은 메모리를 사용하라.
Working Set이 메모리에 모두 들어
가 있어야 빠른 속도를 보장한다.
3. ReplSet, Journaling
안전성을 위해서 Replica Set과
Journaling을 기본으로 사용한다.
4. 최신 버전을 사용하자.
1.8.x 보다는 2.0.x 버전을…
같은 버전에서도 최신 버전을…
Global Write Lock이 2.0.x에서
좀 더 개선됨.
4. Scale Up > Shard
샤딩 보다는 Scale UP을 먼저 하자.
메모리 증가, HDD -> SDD
샤드키를 잘 만드는 것보다 이게 더
쉽다.
Thank You!
그 외의 이야기들…

Mais conteúdo relacionado

Mais procurados

Stash 사용자 교육
Stash 사용자 교육Stash 사용자 교육
Stash 사용자 교육Byeongsu Kang
 
게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가Seungmo Koo
 
게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCP게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCPSeungmo Koo
 
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)Seungmo Koo
 
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기Jaeseung Ha
 
Advanced nGrinder 2nd Edition
Advanced nGrinder 2nd EditionAdvanced nGrinder 2nd Edition
Advanced nGrinder 2nd EditionJunHo Yoon
 
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013devCAT Studio, NEXON
 
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화Seungmo Koo
 
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기Chanwoong Kim
 
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍Seungmo Koo
 
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기Jinuk Kim
 
게임서버프로그래밍 #2 - IOCP Adv
게임서버프로그래밍 #2 - IOCP Adv게임서버프로그래밍 #2 - IOCP Adv
게임서버프로그래밍 #2 - IOCP AdvSeungmo Koo
 
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스Dan Kang (강동한)
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012devCAT Studio, NEXON
 
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰승민 백
 
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉iFunFactory Inc.
 
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기YoungSu Son
 
오픈소스 성능 최적화 보고서 ch07. Infinispan
오픈소스 성능 최적화 보고서 ch07. Infinispan오픈소스 성능 최적화 보고서 ch07. Infinispan
오픈소스 성능 최적화 보고서 ch07. InfinispanHyeonSeok Choi
 
Concurrent programming
Concurrent programmingConcurrent programming
Concurrent programmingByeongsu Kang
 
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013devCAT Studio, NEXON
 

Mais procurados (20)

Stash 사용자 교육
Stash 사용자 교육Stash 사용자 교육
Stash 사용자 교육
 
게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가게임서버프로그래밍 #8 - 성능 평가
게임서버프로그래밍 #8 - 성능 평가
 
게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCP게임서버프로그래밍 #1 - IOCP
게임서버프로그래밍 #1 - IOCP
 
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)
사설 서버를 막는 방법들 (프리섭, 더이상은 Naver)
 
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기
NDC2018 안드로이드+유니티 네이티브 프로파일링 삽질기
 
Advanced nGrinder 2nd Edition
Advanced nGrinder 2nd EditionAdvanced nGrinder 2nd Edition
Advanced nGrinder 2nd Edition
 
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013
이승재, M2 AI코드 개발 생산성 향상 사례, NDC2013
 
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
 
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
 
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
게임서버프로그래밍 #4 - 멀티스레드 프로그래밍
 
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기
NDC14 모바일 게임서비스를 위한 사설 클라우드 구축/운영 분투기
 
게임서버프로그래밍 #2 - IOCP Adv
게임서버프로그래밍 #2 - IOCP Adv게임서버프로그래밍 #2 - IOCP Adv
게임서버프로그래밍 #2 - IOCP Adv
 
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
 
임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012임태현, MMO 서버 개발 포스트 모템, NDC2012
임태현, MMO 서버 개발 포스트 모템, NDC2012
 
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
[NDC_16] 캐릭터 한 달에 하나씩 업데이트 하기 : '최강의 군단' 스킬 개발 툴 포스트 모템과 차기작 '건파이트 맨션' 툴 프리뷰
 
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
NDC14 범용 게임 서버 프레임워크 디자인 및 테크닉
 
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기
클라우드 & 모바일 환경에서 알아야 할 성능 품질 이야기
 
오픈소스 성능 최적화 보고서 ch07. Infinispan
오픈소스 성능 최적화 보고서 ch07. Infinispan오픈소스 성능 최적화 보고서 ch07. Infinispan
오픈소스 성능 최적화 보고서 ch07. Infinispan
 
Concurrent programming
Concurrent programmingConcurrent programming
Concurrent programming
 
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
전형규, M2 클라이언트 스레딩 아키텍쳐, NDC2013
 

Mais de DaeMyung Kang

How to use redis well
How to use redis wellHow to use redis well
How to use redis wellDaeMyung Kang
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashingDaeMyung Kang
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache keyDaeMyung Kang
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash DaeMyung Kang
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advanceDaeMyung Kang
 
Massive service basic
Massive service basicMassive service basic
Massive service basicDaeMyung Kang
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101DaeMyung Kang
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better EngineerDaeMyung Kang
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_finalDaeMyung Kang
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offsetDaeMyung Kang
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lakeDaeMyung Kang
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbieDaeMyung Kang
 

Mais de DaeMyung Kang (20)

Count min sketch
Count min sketchCount min sketch
Count min sketch
 
Redis
RedisRedis
Redis
 
Ansible
AnsibleAnsible
Ansible
 
Why GUID is needed
Why GUID is neededWhy GUID is needed
Why GUID is needed
 
How to use redis well
How to use redis wellHow to use redis well
How to use redis well
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashing
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache key
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advance
 
Massive service basic
Massive service basicMassive service basic
Massive service basic
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better Engineer
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_final
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offset
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lake
 
Redis acl
Redis aclRedis acl
Redis acl
 
Coffee store
Coffee storeCoffee store
Coffee store
 
Scalable webservice
Scalable webserviceScalable webservice
Scalable webservice
 
Number system
Number systemNumber system
Number system
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbie
 

Mongo db 잡학상식