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
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   /


 •
•
                      • 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
• mongostat
 • idx missing, faults,global locked
 • db.serverStatus & rs.status
• Replication
 •            oplogsize //
    slave     clone

  • --fastsync + snapshot
  • --maxConns
  • --replSet=<set_name>/<seed list>
   • seed list          1 arbitor
• Some collections
   • local.oplog.rs/replset.minvalid
   • $cmd
   • system.indexes
• GridFS
 •           :Write once, Read many.

 • fs.files _id ETag
 • file content hash
 • gc
 • * Node.js
• Update/Delete
 •           ,Schema          padding

   • In-place update
 • Mark delete            remove

   •
 • remove() ,          drop
• Group
 • 4Mb              MR

• db.eval & Javascript
 •                           db

 •                       scope


 •
• DBRef
 •
• MR
 •
 •
          MR

   • v8
Question?




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

More Related Content

What's hot (20)

Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
Hiroshi SHIBATA
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
Hiroshi SHIBATA
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
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
 
What's new in RubyGems3
What's new in RubyGems3What's new in RubyGems3
What's new in RubyGems3
Hiroshi SHIBATA
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
Hiroshi SHIBATA
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
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 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
 
232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현
NAVER D2
 
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
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
Hiroshi SHIBATA
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
Andrei Pangin
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
Hiroshi SHIBATA
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Gems on Ruby
Gems on RubyGems on Ruby
Gems on Ruby
Hiroshi SHIBATA
 
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
Matt Kocubinski
 
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
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
sunilar0ra
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
Hiroshi SHIBATA
 
OSS Security the hard way
OSS Security the hard wayOSS Security the hard way
OSS Security the hard way
Hiroshi SHIBATA
 
MySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAsMySQL Replication Troubleshooting for Oracle DBAs
MySQL Replication Troubleshooting for Oracle DBAs
Sveta Smirnova
 
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
 
Dependency Resolution with Standard Libraries
Dependency Resolution with Standard LibrariesDependency Resolution with Standard Libraries
Dependency Resolution with Standard Libraries
Hiroshi SHIBATA
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
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 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
 
232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현232 deview2013 oss를활용한분산아키텍처구현
232 deview2013 oss를활용한분산아키텍처구현
NAVER D2
 
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
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
Hiroshi SHIBATA
 
The Art of JVM Profiling
The Art of JVM ProfilingThe Art of JVM Profiling
The Art of JVM Profiling
Andrei Pangin
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
Hiroshi SHIBATA
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal ArchitectureDissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
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
Matt Kocubinski
 
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
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
sunilar0ra
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 

Similar to 视觉中国的MongoDB应用实践(QConBeijing2011) (20)

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
 
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
 
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_v2
tianyi5212222
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
Wyatt Fang
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
Lin Jen-Shin
 
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.
 
Why MariaDB?
Why MariaDB?Why MariaDB?
Why MariaDB?
Colin Charles
 
Gotszling mogo db-membase
Gotszling mogo db-membaseGotszling mogo db-membase
Gotszling mogo db-membase
GiltTech
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing
yiditushe
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程
George Ang
 
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
 
Mongo db roma replication and sharding
Mongo db roma replication and shardingMongo db roma replication and sharding
Mongo db roma replication and sharding
Guglielmo Incisa Di Camerana
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
Mauro Pompilio
 
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
 
Achieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with ChefAchieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with Chef
Matt Ray
 
Impression of Rails 3
Impression of Rails 3Impression of Rails 3
Impression of Rails 3
Kosuke Matsuda
 
Chef for OpenStack - OpenStack Fall 2012 Summit
Chef for OpenStack  - OpenStack Fall 2012 SummitChef for OpenStack  - OpenStack Fall 2012 Summit
Chef for OpenStack - OpenStack Fall 2012 Summit
Matt Ray
 
Chef for OpenStack- Fall 2012.pdf
Chef for OpenStack- Fall 2012.pdfChef for OpenStack- Fall 2012.pdf
Chef for OpenStack- Fall 2012.pdf
OpenStack Foundation
 
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
 
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
 
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_v2
tianyi5212222
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
Wyatt Fang
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
Lin Jen-Shin
 
Gotszling mogo db-membase
Gotszling mogo db-membaseGotszling mogo db-membase
Gotszling mogo db-membase
GiltTech
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing
yiditushe
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程
George Ang
 
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
 
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
 
Achieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with ChefAchieving Infrastructure Portability with Chef
Achieving Infrastructure Portability with Chef
Matt Ray
 
Chef for OpenStack - OpenStack Fall 2012 Summit
Chef for OpenStack  - OpenStack Fall 2012 SummitChef for OpenStack  - OpenStack Fall 2012 Summit
Chef for OpenStack - OpenStack Fall 2012 Summit
Matt Ray
 
Ad

Recently uploaded (20)

AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
The case for on-premises AI
The case for on-premises AIThe case for on-premises AI
The case for on-premises AI
Principled Technologies
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...Cyber security cyber security cyber security cyber security cyber security cy...
Cyber security cyber security cyber security cyber security cyber security cy...
pranavbodhak
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Jeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software DeveloperJeremy Millul - A Talented Software Developer
Jeremy Millul - A Talented Software Developer
Jeremy Millul
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
Co-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using ProvenanceCo-Constructing Explanations for AI Systems using Provenance
Co-Constructing Explanations for AI Systems using Provenance
Paul Groth
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
Ad

视觉中国的MongoDB应用实践(QConBeijing2011)

  • 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. 0: * MongoDB • Out of Memory! • v1.3 * cursor • Perl driver bug,
  • 36. 0: 1: • • 2 2: • driver • driver
  • 37. 1:50x 502 Bad Gateway * GridFS • Perl Plack Starman/Plack Nginx Proxy store MongoDB Disk Cache * GridFS • Nginx proxy_store •
  • 38. 1:50x 504 Gateway timeout • • • Perl nginx_errorlog 5 mongodb.log • client
  • 39. 1:50x 3 • XFS pre-allocation FS • for i in {1..50} do echo $i head -c 2146435072 /dev/zero > $db.$i done
  • 40. 2: • Mongod crash • Why? • Map/Reduce / •
  • 41. • 10 • MongoDB • Repair 5 • • 10 : http://czone.chinavisual.com/art/4cad0e08497959d621a10000.html
  • 42. • MongoDB • • cluster : slave •
  • 43. 1 • --syndelay • 60s(default) => 15~30s • IO • fsync •
  • 44. 2 • 1.6.3, Master-Slaves RelicaSets • 1 Primary + 2 Secondary • 4g-8g • w=2 •
  • 47. 4: RS fail-over • MongoDB • Primary kill 2 secondary • secondary
  • 48. 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’) • ...
  • 49. 4: RS fail-over 6: ReplicaSet • 1 Primary + 2 Secondary + n Arbitor • •
  • 50. •6 “ ” • ;-( • • ReplicaSet fail-over secondary • Primary , •
  • 51. 1.8 • 1.8 • journaling file • mongod -dur • crash repairDatabase •
  • 52. • GridFS • 10mb-500mb •
  • 53. • GridFS • Nginx proxy_store • MongoDB • ,Plack app • prefork
  • 54. • GridFS • • slaveOK • Plack app Twiggy AnyEvent
  • 55. 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
  • 57. Primary • Slave only IDC Secondary1 MongoD Secondary2 ReplicaSet1 • priority 0 VPN • VPN 2 IDC Slave1
  • 58. >300ms • MongoDB
  • 59. MongoDB • snapshot • • local.oplog.rs ( tailable cursor) • • replay oplog
  • 60. 2 • GridFS • VPN
  • 61. VPN • GridFS • • BSON HTTP • mongod
  • 62. 7 • • • • unix : http://czone.chinavisual.com/art/4c05e7be4979596b7e570000.html
  • 63. Auto-sharding • 1.6GA Auto-sharding • •2 1 • •
  • 64. • Shard_key • shard key chunk • 4sq • shard_key • counting • chunk • balancer
  • 65. • shard • shard • • 1.8
  • 66. • • MongoDB auto-shard • GA • 2.0+ ?
  • 67. MongoDB • MySQL Web • Schema free • Geo • MySQL • GridFS • sharding • Auto-sharding shared_key balancing 1.8/2.0
  • 68. • mongostat • idx missing, faults,global locked • db.serverStatus & rs.status
  • 69. • Replication • oplogsize // slave clone • --fastsync + snapshot • --maxConns • --replSet=<set_name>/<seed list> • seed list 1 arbitor
  • 70. • Some collections • local.oplog.rs/replset.minvalid • $cmd • system.indexes
  • 71. • GridFS • :Write once, Read many. • fs.files _id ETag • file content hash • gc • * Node.js
  • 72. • Update/Delete • ,Schema padding • In-place update • Mark delete remove • • remove() , drop
  • 73. • Group • 4Mb MR • db.eval & Javascript • db • scope •
  • 74. • DBRef • • MR • • MR • v8
  • 75. Question? :http://czone.chinavisual.com/art/4b45015461be3def730e6351.html