SlideShare a Scribd company logo
QCon beijing 2011



                                                                   MongoDB




: http://czone.chinavisual.com/art/4b4501548f47e8ef73699a0c.html
About.me

•         ( nightsailer)

    • @nightsailer //twitter,sina,linkedin,
      github ...
    • nightsailer # gmail.com
    • http://nightsailer.com/
MongoDB

  NoSQL      ?
Auto-shard           ?

• No! 08
                           K/V
    MySQL
App




               MMM
                                                                  • MySQL   Percona
                                           Mysql(Master-Master)
                                                                   Master-Master-Slaves
                                                                  • HA:MMM
Mysql(M1)                      Mysql(M2)




       Slave           Slave
•
•       schema

    •
•
•
MySQL
*                JSON

    • schema
    •
*

    • schema
    •          query
App




            MMM/vdb11




                                                        KV
                                            KV1



                                                  KV2

Mysql(M1)                 Mysql(M2)




       Slave      Slave
Memcached

•
     Memcached

•                KV
•   PHP/Perl

•   Memcached

•
•
•
• Flare
• Repcached
• Redis
• TC/TT
Flare

•      cluster     ,


•      Memcached
1

•
•
    •
    •
    •       ;-(
• Cassandra
 •
• CouchDB
 •
MongoDB
•                Redis

• Document
•            Redis

• MySQL              ,

• MySQL
MySQL   MongoDB

•          MySQL     MongoDB


•        MySQL <=> MongoDB


•
MySQL

• Transaction
• Joins
•
•
•1   1            90%

•     35   table => 10 collection

•            happy!
MongoDB,

           GridFS

•
•
    •   MogileFS
MongoDB,

• SourceForge
•
• 10gen         mailing-list


• NoSQL                MongoDB
1
•
    comments:{

      _id:ObjectId(‘xxx’),

      art_id:2,

      content: ‘           ...’,

      replied_on:    12233

      created_on: 12222

      replies: [{

        _id: ObjectId(‘xxx’),

        content: ‘     ,     ...’,

        replies:[]

      }]}
2
           /       :

•
•
•
               /       /
    ...)

•
2


• db.activity_stream.feed (
• db.activity_stream.user         )

• db.activity_stream(
2

feed

•
    •                follower
        collection
    •                  embed list
3:
    1: Regex

•
    2: Sphinx

•              xml

•
3:
        3:        Array/List      ($all)

•
•            PHP-SCWS

•             :

    •                          oplog
MongoDB

• Scons,         Python

• boost(CentOS)
• static link mongod
• tcmalloc
•                MongoDB( ICC
COMMON_CXXFLAGS='-fp-model source -unroll2   -axSSE4.1,SSE4.2 -xSSE3 -
static-intel -fpic -fno-strict-aliasing'

CXXFLAGS="-O3 -ipo   -static-libgcc $COMMON_CXXFLAGS"

scons --release --static --extrapath=/opt/local --cxx=$CXX --icc --
extralib='tcmalloc_minimal' --icc-cxxflags="$CXXFLAGS" --icc-
cppflags="$CPPFLAGS" -c $BIN_SERVER

scons -j4 --release --static --extrapath=/opt/local --cxx=$CXX --icc
--extralib='tcmalloc_minimal' --icc-cxxflags="$CXXFLAGS" --icc-
cppflags="$CPPFLAGS" $BIN_SERVER
•
•
•            Raid10

•
    • XFS
    • Ext4 (?)
PHP-FPM
                                          2009/6,       0.9/1.0

                                    • 1 Master + 2 slaves
                      Nginx

              Mongod Master)




                  Gearman-workers   • 1m
                                    • 20g
                  Mongod Slave)




Gearman-workers
                                    • Dell 2850/4g(Master)   2*Dell
                                      2950/4g(
*          Slave

•
* lvm snapshot
•
• fsync & lock db
* mongodump

•
• mongostat / vmstat / iostat
• collectd
  •        : json-rest+perl plugin

•         Munion / Nagios ...
MongoDB

                              • CPU
                              •                                        4G

                              •                                   IO


:http://czone.chinavisual.com/art/4c7918b74979590970b80000.html
6




:http://czone.chinavisual.com/art/4b45015496ddabef73f49197.html
Why?
•                   Map/Reduce       /


•
•                                  1.6+

     •
**       reIndex repairDatabase,
0:

* MongoDB

• Out of Memory!
•        v1.3
*       cursor

• Perl driver    bug,
0:
    1:

•
•                          2
    2:

•
              driver

•                 driver
1:50x
                                             502 Bad Gateway
                                             * GridFS

                                                 •      Perl Plack
  Starman/Plack                   Nginx




                  Proxy store




MongoDB
                                Disk Cache
                                             *       GridFS

                                                 • Nginx   proxy_store
                                                  •
1:50x
504 Gateway timeout
    •
    •
    • Perl            nginx_errorlog
             5          mongodb.log

•                                 client
1:50x
    3

•               XFS                      pre-allocation FS

•
        for i in {1..50}
        do
            echo $i
            head -c 2146435072 /dev/zero > $db.$i
        done
2:

• Mongod crash
•                Why?

  •               Map/Reduce   /


 •
: http://czone.chinavisual.com/art/4cad0e08497959d621a10000.html
•
                      • 10
                      • MongoDB
                       • Repair                                    5

                       •
                       •       10
: http://czone.chinavisual.com/art/4cad0e08497959d621a10000.html
• MongoDB
 •
 • cluster   :   slave

 •
1

•                      --syndelay

    • 60s(default) => 15~30s
    • IO
•                          fsync

    •
2

•          1.6.3,     Master-Slaves RelicaSets

    • 1 Primary + 2 Secondary
•                   4g-8g

•                     w=2

    •
5

•
•
•
•
:http://czone.chinavisual.com/art/4bd19d3b4979593e1a350000.html
4: RS fail-over


• MongoDB
 • Primary             kill   2
     secondary
 •         secondary
4: RS fail-over

•          2   Arbitor
    •   $ mongod --bind_ip 127.0.0.1,192.168.8.10 --
        replSet rs10 --oplogSize 1 ...

    • > rs.addArb(‘192.168.8.10:27020’)
    • ...
4: RS fail-over

    6:             ReplicaSet

• 1 Primary + 2 Secondary + n Arbitor
•
•
•6          “ ”

  •                     ;-(

  •
•          ReplicaSet   fail-over
  secondary

• Primary          ,

 •
1.8

• 1.8
  • journaling file
  • mongod -dur
  • crash            repairDatabase

•
• GridFS
 •
           10mb-500mb

 •
• GridFS
  •           Nginx proxy_store

• MongoDB
•               ,Plack app

  • prefork
• GridFS
  •
•           slaveOK

• Plack app       Twiggy   AnyEvent
Starman workers/PSGI
                              Starman




             RS02
                                                 Nginx




                    Gearman




                      127.0.0.1:9001

                      127.0.0.1:9002

                      127.0.0.1:9003

                      127.0.0.1:9004    Twiggy/PSGI
             RS01




                    (slaveOK)
Sencondary
•
•
•
Primary


                                           •                        Slave only
                               IDC




Secondary1
                                               MongoD
                Secondary2


              ReplicaSet1
                                               • priority       0
                                     VPN

                                           • VPN            2
                         IDC




     Slave1
•               >300ms

    • MongoDB
•       MongoDB

    •   snapshot

•
    •     local.oplog.rs (   tailable cursor)

    •
    •               replay oplog
•        2

• GridFS
•     VPN
•              VPN

•     GridFS

•
    • BSON             HTTP


•                    mongod
7

                                                                   •
                                                                       •
                                                                       •
                                                                   •           unix




: http://czone.chinavisual.com/art/4c05e7be4979596b7e570000.html
Auto-sharding

• 1.6GA   Auto-sharding

 •
•2        1

 •
 •
• Shard_key
 • shard key        chunk

   • 4sq
 • shard_key
• counting
 •          chunk

• balancer
•
    •         shard


    •             shard

•
•       1.8
•
• MongoDB    auto-shard

• GA
  • 2.0+ ?
MongoDB
• MySQL Web
• Schema free
• Geo
• MySQL
• GridFS
•                            sharding

• Auto-sharding shared_key   balancing
             1.8/2.0
Question?




      :http://czone.chinavisual.com/art/4b45015461be3def730e6351.html

More Related Content

What's hot

Gemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on Ruby
Hiroshi SHIBATA
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
Andrei Pangin
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
Hiroshi SHIBATA
 
The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
Hiroshi SHIBATA
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
Hiroshi SHIBATA
 
Toster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability OptionsToster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability Options
Fabio Akita
 
Bh ad-12-stealing-from-thieves-saher-slides
Bh ad-12-stealing-from-thieves-saher-slidesBh ad-12-stealing-from-thieves-saher-slides
Bh ad-12-stealing-from-thieves-saher-slidesMatt Kocubinski
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101ConFoo
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
Hiroshi SHIBATA
 
Mongo DBを半年運用してみた
Mongo DBを半年運用してみたMongo DBを半年運用してみた
Mongo DBを半年運用してみた
Masakazu Matsushita
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
Leszek Urbanski
 
Linux Cluster next generation
Linux Cluster next generationLinux Cluster next generation
Linux Cluster next generation
samsolutionsby
 
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
Jeongkyu Shin
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
Hiroshi SHIBATA
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap Dumps
Andrei Pangin
 
Lets have a look at Apple's Metal Framework
Lets have a look at Apple's Metal FrameworkLets have a look at Apple's Metal Framework
Lets have a look at Apple's Metal Framework
LINE Corporation
 
Java 7 Preview
Java 7 PreviewJava 7 Preview
Java 7 Preview
Alex Miller
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
Hiroshi SHIBATA
 

What's hot (19)

Gemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on Ruby
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
 
The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
 
Toster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability OptionsToster - Understanding the Rails Web Model and Scalability Options
Toster - Understanding the Rails Web Model and Scalability Options
 
Bh ad-12-stealing-from-thieves-saher-slides
Bh ad-12-stealing-from-thieves-saher-slidesBh ad-12-stealing-from-thieves-saher-slides
Bh ad-12-stealing-from-thieves-saher-slides
 
Scalable Architecture 101
Scalable Architecture 101Scalable Architecture 101
Scalable Architecture 101
 
The Future of library dependency manageement of Ruby
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
 
Mongo DBを半年運用してみた
Mongo DBを半年運用してみたMongo DBを半年運用してみた
Mongo DBを半年運用してみた
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Linux Cluster next generation
Linux Cluster next generationLinux Cluster next generation
Linux Cluster next generation
 
111214 node conf
111214 node conf111214 node conf
111214 node conf
 
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
연구자 및 교육자를 위한 계산 및 분석 플랫폼 설계 - PyCon KR 2015
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap Dumps
 
Lets have a look at Apple's Metal Framework
Lets have a look at Apple's Metal FrameworkLets have a look at Apple's Metal Framework
Lets have a look at Apple's Metal Framework
 
Java 7 Preview
Java 7 PreviewJava 7 Preview
Java 7 Preview
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
 

Similar to MongoDB开发应用实践

High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011
Tim Y
 
Novalug 07142012
Novalug 07142012Novalug 07142012
Novalug 07142012
Mandi Walls
 
SCALE 10x Build a Cloud Day
SCALE 10x Build a Cloud DaySCALE 10x Build a Cloud Day
SCALE 10x Build a Cloud Day
Chef Software, Inc.
 
mtl_rubykaigi
mtl_rubykaigimtl_rubykaigi
mtl_rubykaigi
Hirotomo Oi
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
tianyi5212222
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
http403
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
Chris Richardson
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
Colin Charles
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程George Ang
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijingyiditushe
 
Gotszling mogo db-membase
Gotszling mogo db-membaseGotszling mogo db-membase
Gotszling mogo db-membaseGiltTech
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
Server Density
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage ServerLin Jen-Shin
 
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
Alex Gorbachev
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment StrategyMongoDB
 
hbstudy@bpstudy#50 配布用
hbstudy@bpstudy#50 配布用hbstudy@bpstudy#50 配布用
hbstudy@bpstudy#50 配布用Toshiaki Baba
 
MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)
Colin Charles
 
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with MinecraftReplatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
VMware Tanzu
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
Mauro Pompilio
 

Similar to MongoDB开发应用实践 (20)

High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011
 
Novalug 07142012
Novalug 07142012Novalug 07142012
Novalug 07142012
 
SCALE 10x Build a Cloud Day
SCALE 10x Build a Cloud DaySCALE 10x Build a Cloud Day
SCALE 10x Build a Cloud Day
 
mtl_rubykaigi
mtl_rubykaigimtl_rubykaigi
mtl_rubykaigi
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing
 
Gotszling mogo db-membase
Gotszling mogo db-membaseGotszling mogo db-membase
Gotszling mogo db-membase
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
 
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
MOW2010: 1TB MySQL Database Migration and HA Infrastructure by Alex Gorbachev...
 
Deployment Strategy
Deployment StrategyDeployment Strategy
Deployment Strategy
 
hbstudy@bpstudy#50 配布用
hbstudy@bpstudy#50 配布用hbstudy@bpstudy#50 配布用
hbstudy@bpstudy#50 配布用
 
MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)MariaDB: in-depth (hands on training in Seoul)
MariaDB: in-depth (hands on training in Seoul)
 
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with MinecraftReplatforming Legacy Packaged Applications: Block-by-Block with Minecraft
Replatforming Legacy Packaged Applications: Block-by-Block with Minecraft
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 

More from iammutex

Scaling Instagram
Scaling InstagramScaling Instagram
Scaling Instagram
iammutex
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
iammutex
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
iammutex
 
NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析
iammutex
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
iammutex
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide
iammutex
 
skip list
skip listskip list
skip list
iammutex
 
Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Models
iammutex
 
Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告
iammutex
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
iammutex
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
iammutex
 
What every data programmer needs to know about disks
What every data programmer needs to know about disksWhat every data programmer needs to know about disks
What every data programmer needs to know about disks
iammutex
 
redis运维之道
redis运维之道redis运维之道
redis运维之道
iammutex
 
Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011iammutex
 
[译]No sql生态系统
[译]No sql生态系统[译]No sql生态系统
[译]No sql生态系统
iammutex
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbase
iammutex
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
iammutex
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
iammutex
 

More from iammutex (20)

Scaling Instagram
Scaling InstagramScaling Instagram
Scaling Instagram
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 
NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide
 
skip list
skip listskip list
skip list
 
Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Models
 
Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
 
What every data programmer needs to know about disks
What every data programmer needs to know about disksWhat every data programmer needs to know about disks
What every data programmer needs to know about disks
 
Ooredis
OoredisOoredis
Ooredis
 
Ooredis
OoredisOoredis
Ooredis
 
redis运维之道
redis运维之道redis运维之道
redis运维之道
 
Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011
 
[译]No sql生态系统
[译]No sql生态系统[译]No sql生态系统
[译]No sql生态系统
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbase
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 

Recently uploaded

SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 

Recently uploaded (20)

SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 

MongoDB开发应用实践

  • 1. QCon beijing 2011 MongoDB : http://czone.chinavisual.com/art/4b4501548f47e8ef73699a0c.html
  • 2. About.me • ( nightsailer) • @nightsailer //twitter,sina,linkedin, github ... • nightsailer # gmail.com • http://nightsailer.com/
  • 3. MongoDB NoSQL ? Auto-shard ? • No! 08 K/V MySQL
  • 4. App MMM • MySQL Percona Mysql(Master-Master) Master-Master-Slaves • HA:MMM Mysql(M1) Mysql(M2) Slave Slave
  • 5. • • schema • • •
  • 6. MySQL * JSON • schema • * • schema • query
  • 7. App MMM/vdb11 KV KV1 KV2 Mysql(M1) Mysql(M2) Slave Slave
  • 8. Memcached • Memcached • KV
  • 9. PHP/Perl • Memcached • • •
  • 10. • Flare • Repcached • Redis • TC/TT
  • 11. Flare • cluster , • Memcached
  • 12. 1 • • • • • ;-(
  • 13. • Cassandra • • CouchDB •
  • 14. MongoDB • Redis • Document • Redis • MySQL , • MySQL
  • 15. MySQL MongoDB • MySQL MongoDB • MySQL <=> MongoDB •
  • 17. • •1 1 90% • 35 table => 10 collection • happy!
  • 18. MongoDB, GridFS • • • MogileFS
  • 19. MongoDB, • SourceForge • • 10gen mailing-list • NoSQL MongoDB
  • 20. 1 • comments:{ _id:ObjectId(‘xxx’), art_id:2, content: ‘ ...’, replied_on: 12233 created_on: 12222 replies: [{ _id: ObjectId(‘xxx’), content: ‘ , ...’, replies:[] }]}
  • 21. 2 / : • • • / / ...) •
  • 22. 2 • db.activity_stream.feed ( • db.activity_stream.user ) • db.activity_stream(
  • 23. 2 feed • • follower collection • embed list
  • 24. 3: 1: Regex • 2: Sphinx • xml •
  • 25. 3: 3: Array/List ($all) • • PHP-SCWS • : • oplog
  • 26. MongoDB • Scons, Python • boost(CentOS) • static link mongod • tcmalloc
  • 27. MongoDB( ICC COMMON_CXXFLAGS='-fp-model source -unroll2 -axSSE4.1,SSE4.2 -xSSE3 - static-intel -fpic -fno-strict-aliasing' CXXFLAGS="-O3 -ipo -static-libgcc $COMMON_CXXFLAGS" scons --release --static --extrapath=/opt/local --cxx=$CXX --icc -- extralib='tcmalloc_minimal' --icc-cxxflags="$CXXFLAGS" --icc- cppflags="$CPPFLAGS" -c $BIN_SERVER scons -j4 --release --static --extrapath=/opt/local --cxx=$CXX --icc --extralib='tcmalloc_minimal' --icc-cxxflags="$CXXFLAGS" --icc- cppflags="$CPPFLAGS" $BIN_SERVER
  • 29. Raid10 • • XFS • Ext4 (?)
  • 30. PHP-FPM 2009/6, 0.9/1.0 • 1 Master + 2 slaves Nginx Mongod Master) Gearman-workers • 1m • 20g Mongod Slave) Gearman-workers • Dell 2850/4g(Master) 2*Dell 2950/4g(
  • 31. * Slave • * lvm snapshot • • fsync & lock db * mongodump •
  • 32. • mongostat / vmstat / iostat • collectd • : json-rest+perl plugin • Munion / Nagios ...
  • 33. MongoDB • CPU • 4G • IO :http://czone.chinavisual.com/art/4c7918b74979590970b80000.html
  • 35. Why? • Map/Reduce / • • 1.6+ • ** reIndex repairDatabase,
  • 36. 0: * MongoDB • Out of Memory! • v1.3 * cursor • Perl driver bug,
  • 37. 0: 1: • • 2 2: • driver • driver
  • 38. 1:50x 502 Bad Gateway * GridFS • Perl Plack Starman/Plack Nginx Proxy store MongoDB Disk Cache * GridFS • Nginx proxy_store •
  • 39. 1:50x 504 Gateway timeout • • • Perl nginx_errorlog 5 mongodb.log • client
  • 40. 1:50x 3 • XFS pre-allocation FS • for i in {1..50} do echo $i head -c 2146435072 /dev/zero > $db.$i done
  • 41. 2: • Mongod crash • Why? • Map/Reduce / •
  • 43. • 10 • MongoDB • Repair 5 • • 10 : http://czone.chinavisual.com/art/4cad0e08497959d621a10000.html
  • 44. • MongoDB • • cluster : slave •
  • 45. 1 • --syndelay • 60s(default) => 15~30s • IO • fsync •
  • 46. 2 • 1.6.3, Master-Slaves RelicaSets • 1 Primary + 2 Secondary • 4g-8g • w=2 •
  • 49. 4: RS fail-over • MongoDB • Primary kill 2 secondary • secondary
  • 50. 4: RS fail-over • 2 Arbitor • $ mongod --bind_ip 127.0.0.1,192.168.8.10 -- replSet rs10 --oplogSize 1 ... • > rs.addArb(‘192.168.8.10:27020’) • ...
  • 51. 4: RS fail-over 6: ReplicaSet • 1 Primary + 2 Secondary + n Arbitor • •
  • 52. •6 “ ” • ;-( • • ReplicaSet fail-over secondary • Primary , •
  • 53. 1.8 • 1.8 • journaling file • mongod -dur • crash repairDatabase •
  • 54. • GridFS • 10mb-500mb •
  • 55. • GridFS • Nginx proxy_store • MongoDB • ,Plack app • prefork
  • 56. • GridFS • • slaveOK • Plack app Twiggy AnyEvent
  • 57. Starman workers/PSGI Starman RS02 Nginx Gearman 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003 127.0.0.1:9004 Twiggy/PSGI RS01 (slaveOK) Sencondary
  • 59. Primary • Slave only IDC Secondary1 MongoD Secondary2 ReplicaSet1 • priority 0 VPN • VPN 2 IDC Slave1
  • 60. >300ms • MongoDB
  • 61. MongoDB • snapshot • • local.oplog.rs ( tailable cursor) • • replay oplog
  • 62. 2 • GridFS • VPN
  • 63. VPN • GridFS • • BSON HTTP • mongod
  • 64. 7 • • • • unix : http://czone.chinavisual.com/art/4c05e7be4979596b7e570000.html
  • 65. Auto-sharding • 1.6GA Auto-sharding • •2 1 • •
  • 66. • Shard_key • shard key chunk • 4sq • shard_key • counting • chunk • balancer
  • 67. • shard • shard • • 1.8
  • 68. • • MongoDB auto-shard • GA • 2.0+ ?
  • 69. MongoDB • MySQL Web • Schema free • Geo • MySQL • GridFS • sharding • Auto-sharding shared_key balancing 1.8/2.0
  • 70. Question? :http://czone.chinavisual.com/art/4b45015461be3def730e6351.html