SlideShare a Scribd company logo
1 of 54
Text
     2009.4

hongqn@douban.com
•   2005 3

•

•

•
• 2.8M            1/4
•
• 20M        /        500~600/sec
• 23      PC      (1U*15/2U*8)
  • 12
  • 38G memcached
•        1U         (frodo)
    •        AMD Athlon 64 1.8GHz
    •   1G       160G SATA*2
•   Gentoo Linux
•   MySQL 5
•   Quixote (a Python web framework)
•   Lighttpd + SCGI (shire)
•   Memcached (!)
Internet




                  Lighttpd

                SCGI



          App

                       FS




MySQL   Memcache             Static Files
Gentoo Linux
•
    • emerge mysql
    • ebuild          patch
•
•
    • GLSA(Gentoo Linux Security Advisories)
MySQL

•   The world’s most popular open source database

•            /             ==> MyISAM

•                ==> InnoDB

•   Replicate for backup
Python

•
•   Battery Included

•
•
    •   CPUG: http://python.cn/
Quixote
•                             REST         URL
•               Django, TurboGears, Pylons
               ZOPE
• http://www.douban.com/subject/1000001
     # luz/subject/__init__.py
     def _q_lookup(request, name):
         subject = get_subject(name)
         return lambda req: subject_ui(req, subject)

    # luz/subject/subject_ui.ptl
    def subject_ui [html] (request, subject):
      site_header(request)
      “<h1>%s</h1>” % subject.title
      site_footer(request)
Lighttpd
•
•       SCGI
    • SCGI:               FastCGI
      Quixote
•                  80        lighttpd
                   SCGI    localhost
    Quixote
Memcache
•                                           MySQL
•     libmemcache   python                          Pyrex
      python    3x+
    def get_subject(subject_id):

       subject = mc.get(‘s:’+subject_id)

       if subject is None:

          store.farm.execute(“select xxx, xxx from subject where id=%s”,

                              subject_id)

          subject = Subject(*store.farm.fetchone())

          mc.set(‘s:’+subject_id, subject)

       return subject
• 1.2M   /
• IO
•
•                1U
    •   pippin       meriadoc (      merry)
    •         , 4G          250G SATA*3
•
•                      IP            DNS
    IP -_-b
•                            frodo
    (subversion, trac, etc...)
Internet




        Lighttpd (#$)                               DNS
                                        HTTP
                                        Proxy
                    SCGI


                           App                  Lighttpd (!quot;)

               FS




Static Files          Memcache                    MySQL
•
    • innodb_buffer_pool_size
•
•              IP
• 1.5M   /
•
• IP
•                            IP(BGP)
•                         (arwen)
    • 74G 1w   SATA * 3
    •
•
Internet




                                                               Data
               Lighttpd                                       Mining
                                                               read
                   SCGI                               write



                          App                 Replicate




                                     MySQL                    MySQL
                                     Master                   Slave


                          Memcache
Static Files
• 2M              /
•                     IO
  •
       , etc...
•
•                               4G   250G SATA*3
•                                10000
    •   mod_rewrite       URL
•              lighttpd              mod_memcache

    •           IO
•                web
    •
•
Internet

                                                                store.farm
                                              App

                                                                                       MySQL
                                SCGI
                                                                                       Master
          Lighttpd                                         Memcache                        Replicate
                                                                     store.farmr
        HTTP Proxy
                                   WebDAV   Web Service
                                                                                                 Replicate
      Lighttpd
(w/ mod_memcache)

                                                                                     MySQL               write

                                                                                     Slave
                                            Spiders
                     Lighttpd
                     WebDAV
                                                          Memcache
Static Files


                                                                                    !quot;#$%
                                                                                       read
                                                                                                        Data
                                                                                                       Mining
                                                                                   MySQL
                                                                                   Slave
•   store          farmr
•                replicate delay
    •
    •

    •                          cache
        •
•

    •   ......             but it works
replicate delay
def get_subject(sid):
   sbj = mc.get(‘s:’+sid)
   if sbj is None:
      sbj = flush_subject(sid, store.farmr)
      return sbj

def flush_subject(sid, cursor=None):
   cursor = cursor or store.farm
   cursor.execute(“select ... from subject”)
   subject = Subject(*cursor.fetchone())
   mc.set(‘s:’+sid, subject)
   return subject

def update_subject(subject, props):
   store.farm.execute(“update subject ...”)
   store.farm.connection.commit()
   flush_subject(subject.id, store.farm)
• 2.5M       /
•
  •      /
• SATA
•
•   Scale Up               1U
    •   16G        147G SCSI *2 + 500G SATA
    •   SCSI     RAID-0
•       MySQL Slave
•         memcached
•              MyISAM            InnoDB
    •
•                       Sphinx
Internet
                                                     Sphinx


                                                                                          MySQL
                                                                                          Master
                                                                    store.farm
                                                Web Service
                                                                                                    Replicate
          Lighttpd
                                SCGI

                                              App
        HTTP Proxy

                                                                                         Memcache
      Lighttpd
(w/ mod_memcache)                  WebDAV
                                                                           store.farmr
                                                               Memcache

                     Lighttpd
                                            Web Service
                     WebDAV

                                                                                          MySQL
Static Files
                                                                                          Slave

                                            Spiders


                                                              Memcache
                                                                                         Memcache
• 5.2M   /
•
• Web        IO


•
•
•                             :)
    •
    •
    •
•        3 1U             4        32G        1T SATA * 3
•                      otho.douban.com        lotho.douban.com
    •   lighttpd 1.5 with aio support
    •        LVS
•   Scale Up:                            4G -> 8G
Internet


                          www.douban.com          otho.douban.com


                                                    LVS LB
                                                   (Master)
          Lighttpd
                                                                        Lighttpd 1.5
                                                                      (w/ mod_cache)
          HTTP Proxy




          Lighttpd                                                  Keepalived

                                                   LVS LB
                                                  (backup)
                       Lighttpd
                                                                        Lighttpd 1.5
                       WebDAV
                                                                      (w/ mod_cache)

Static Files
write




                                      !quot;#$%
                replicate
                                         read        Data
                                                    Mining
                                     MySQL
MySQL
                                     Slave
Master

                                             read
    Replicate
                            write




                                      !quot;#$%
                                           Data
                                          Mining
MySQL
Slave
• 6.4M       /   (5M PV)
•
  •
 • CPU   memcache          /
•
    •   lighttpd     mod_scgi     round-robin
    •   lighttpd 1.5
    •   mod_proxy
        •   proxy.balance = fair (load based, passive
            balancing)
•
•           spread
Internet


                                                     Lighttpd

                                                       SCGI
                              HTTP Proxy

                                                       App      Memcache
          Lighttpd

          HTTP Proxy


                                            spread
                              HTTP Proxy
          Lighttpd


                                                     Lighttpd
                          Log
                       Aggregator                      SCGI
                                           spread

                       Lighttpd
                                                                Memcache
                                                       App
                       WebDAV
Static Files
• 11M      /      3
•
• Sphinx
•
•
           load
•
    •
    •
• Sphinx -> Xapian
• MogileFS
•   libmemcache -> libmemcached              consistent
    hash    memcache
    •       libmemcached consistent hash           bug
•                              CPU
    •       libmemcached failover           bug
•       nginx     lighttpd   load balance
•                            spread
    •           nginx
!quot;
             Master

                       replicate

replicate
                                                !quot;
                                   %&'()
                                                Slave
               #$
              Master                                     read
                       replicate
                                                                  Data
                                                #$        read
                                                Slave            Mining
                                                 write



                                            *+,-
              !quot;
                                            Master
              Slave
                       replicate


             *+,-
              Slave                     write



 replicate
                                         Data
                                    %&'()
                                        Mining
              #$
              Slave
•
•   store.farm[r] -> store.get_cursor(table=‘xxx’,
    ro=True/False)
    def flush_subject(sid, ro=False):
        cursor = store.get_cursor(table=‘subject’, ro=ro)
        cursor.execute(“select ... from subject”)
        subject = Subject(*cursor.fetchone())
        mc.set(‘s:’+sid, subject)
        return subject

•
Internet

                         upload.douban.com otho.douban.com




                                                               Lighttpd 1.5
      signed POST form                 Uploader
                                                             (w/ mod_cache)

               HTTP redirect
                                                             FileStorage
                                  MogileFS Tracker
                                                              Gateway
App




                                                  MogileFS                 MogileFS
                                                   Node                     Node
                               MogileFS
                                Master
Internet


                                                                  App
                                                           SCGI
                                                Lighttpd




                                   HTTP Proxy
  Lighttpd
           HTTP Proxy
                                                                  App
  HTTP Proxy                                               SCGI
                                                Lighttpd
                                   HTTP Proxy
                        Nginx
 Lighttpd

                                   HTTP Proxy




                                                                  App
                        Lighttpd                           SCGI
                                                Lighttpd
                        WebDAV
Static Files
• 13M   /
•                 MogileFS
  •         Tracker DB


•
•       8
    • 32G            CPU
    • (300G SCSI×2 + 1T SATA) × 3
    • (1T SATA × 3) × 5
    •6          2
•       DoubanFS
DoubanFS
•                            hash


•      hash                              hash


•                          Merkle Tree
•      consistent hash
•   WebDAV
•             MogileFS 3     50
Consistent Hash
Merkle Tree
Internet

                         upload.douban.com otho.douban.com




                                                               Lighttpd 1.5
      signed POST form                 Uploader
                                                             (w/ mod_cache)

               HTTP redirect
                                                             FileStorage
                                                              Gateway
App




                                DoubanFS                                   DoubanFS
                                  Node                                       Node
• 16M        /
•
• DoubanFS       IO
•
•       DoubanDB
    •
    •                 MySQL


• MySQL Master
  • failover
  • replicate delay
DoubanDB
•         Key-Value
•     Amazon Dynamo
•              set(key, value), get(key), delete(key)
•   memcache
•         Merkle Tree
•   Consistent Hash
•     TokyoCabinet
•                                DoubanDB
•   DoubanFS 2.0        DoubanDB
!quot;
             Master1

                        replicate

replicate
                                                 !quot;
                                    %&'()
                                                 Slave
               #$
              Master1                                     read
                        replicate
                                                                   Data
                                                 #$        read
                                                 Slave            Mining
                                                  write



                                             *+,-
              !quot;
                                             Master
             Master2
                        replicate


             *+,-
              Slave                      write



 replicate
                                          Data
                                     %&'()
                                         Mining
              #$
             Master2
•       DoubanFS
    •
    •
• ngnix
• www.douban.com       LVS
• RabbitMQ         spread
•
•            profile
• memcache            cache


•              join
•
•
Douban Infrastructure Text Describes Web and Database Architecture

More Related Content

What's hot

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 OptionsFabio Akita
 
Improving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and UnicornImproving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and UnicornSimon Bagreev
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous TaskErin Dees
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnishschoefmax
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http acceleratorno no
 
Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with SlingBertrand Delacretaz
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012Alexandre Morgaut
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking systemJesse Vincent
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011bobmcwhirter
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLZendCon
 
Practicing Continuous Deployment
Practicing Continuous DeploymentPracticing Continuous Deployment
Practicing Continuous Deploymentzeeg
 
SQL Query Tuning: The Legend of Drunken Query Master
SQL Query Tuning: The Legend of Drunken Query MasterSQL Query Tuning: The Legend of Drunken Query Master
SQL Query Tuning: The Legend of Drunken Query MasterZendCon
 
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)err
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)err
 

What's hot (18)

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
 
Improving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and UnicornImproving Your Heroku App Performance with Asset CDN and Unicorn
Improving Your Heroku App Performance with Asset CDN and Unicorn
 
A jar-nORM-ous Task
A jar-nORM-ous TaskA jar-nORM-ous Task
A jar-nORM-ous Task
 
Caching with Varnish
Caching with VarnishCaching with Varnish
Caching with Varnish
 
Varnish http accelerator
Varnish http acceleratorVarnish http accelerator
Varnish http accelerator
 
近未来的並列 LL
近未来的並列 LL近未来的並列 LL
近未来的並列 LL
 
Rapid JCR applications development with Sling
Rapid JCR applications development with SlingRapid JCR applications development with Sling
Rapid JCR applications development with Sling
 
Memcached Study
Memcached StudyMemcached Study
Memcached Study
 
State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012State of the art - server side JavaScript - web-5 2012
State of the art - server side JavaScript - web-5 2012
 
SD, a P2P bug tracking system
SD, a P2P bug tracking systemSD, a P2P bug tracking system
SD, a P2P bug tracking system
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Join-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQLJoin-fu: The Art of SQL Tuning for MySQL
Join-fu: The Art of SQL Tuning for MySQL
 
Apache con 2011 gd
Apache con 2011 gdApache con 2011 gd
Apache con 2011 gd
 
Practicing Continuous Deployment
Practicing Continuous DeploymentPracticing Continuous Deployment
Practicing Continuous Deployment
 
SQL Query Tuning: The Legend of Drunken Query Master
SQL Query Tuning: The Legend of Drunken Query MasterSQL Query Tuning: The Legend of Drunken Query Master
SQL Query Tuning: The Legend of Drunken Query Master
 
Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)Kickin' Ass with Cache-Fu (with notes)
Kickin' Ass with Cache-Fu (with notes)
 
JCR In 10 Minutes
JCR In 10 MinutesJCR In 10 Minutes
JCR In 10 Minutes
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)
 

Similar to Douban Infrastructure Text Describes Web and Database Architecture

豆瓣技术架构的发展历程 @ QCon Beijing 2009
豆瓣技术架构的发展历程 @ QCon Beijing 2009豆瓣技术架构的发展历程 @ QCon Beijing 2009
豆瓣技术架构的发展历程 @ QCon Beijing 2009Qiangning Hong
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程George Ang
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijingyiditushe
 
EC2ナイトセミナプレゼン資料 Rel2
EC2ナイトセミナプレゼン資料 Rel2EC2ナイトセミナプレゼン資料 Rel2
EC2ナイトセミナプレゼン資料 Rel2真一 藤川
 
2008 MySQL Conference Recap
2008 MySQL Conference Recap2008 MySQL Conference Recap
2008 MySQL Conference RecapChris Barber
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & ScalabilityJoseph Scott
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With TerracottaPT.JUG
 
Running A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlRunning A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlPerconaPerformance
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Clusterguestd34230
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMySQLConference
 
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -Yoshiyasu SAEKI
 
Running your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the CloudRunning your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the CloudArun Gupta
 
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storagemoai kids
 
Scaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesScaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesAndrew Turner
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)Stoyan Zhekov
 
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea LuzzardiWhat's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea LuzzardiDocker, Inc.
 

Similar to Douban Infrastructure Text Describes Web and Database Architecture (20)

豆瓣技术架构的发展历程 @ QCon Beijing 2009
豆瓣技术架构的发展历程 @ QCon Beijing 2009豆瓣技术架构的发展历程 @ QCon Beijing 2009
豆瓣技术架构的发展历程 @ QCon Beijing 2009
 
豆瓣技术架构的发展历程
豆瓣技术架构的发展历程豆瓣技术架构的发展历程
豆瓣技术架构的发展历程
 
豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing豆瓣 Qcon2009 Beijing
豆瓣 Qcon2009 Beijing
 
EC2ナイトセミナプレゼン資料 Rel2
EC2ナイトセミナプレゼン資料 Rel2EC2ナイトセミナプレゼン資料 Rel2
EC2ナイトセミナプレゼン資料 Rel2
 
2008 MySQL Conference Recap
2008 MySQL Conference Recap2008 MySQL Conference Recap
2008 MySQL Conference Recap
 
OpenSolaris Web Stack MySQL BOF
OpenSolaris Web Stack MySQL BOFOpenSolaris Web Stack MySQL BOF
OpenSolaris Web Stack MySQL BOF
 
WordPress Performance & Scalability
WordPress Performance & ScalabilityWordPress Performance & Scalability
WordPress Performance & Scalability
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
20080611accel
20080611accel20080611accel
20080611accel
 
Running A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My SqlRunning A Realtime Stats Service On My Sql
Running A Realtime Stats Service On My Sql
 
Blogopolisの裏側
Blogopolisの裏側Blogopolisの裏側
Blogopolisの裏側
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Cluster
 
Make Your Life Easier With Maatkit
Make Your Life Easier With MaatkitMake Your Life Easier With Maatkit
Make Your Life Easier With Maatkit
 
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -
Apache Sparkにおけるメモリ - アプリケーションを落とさないメモリ設計手法 -
 
Running your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the CloudRunning your Java EE 6 Applications in the Cloud
Running your Java EE 6 Applications in the Cloud
 
XS Boston 2008 Network Topology
XS Boston 2008 Network TopologyXS Boston 2008 Network Topology
XS Boston 2008 Network Topology
 
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
小咄:BlazeDS+AMF Client+MySQLで実現するKey-Value Storage
 
Scaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web ServicesScaling Mapufacture on Amazon Web Services
Scaling Mapufacture on Amazon Web Services
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)
 
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea LuzzardiWhat's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
What's New in Docker 1.12 by Mike Goelzer and Andrea Luzzardi
 

More from shen liu

A~Z Of Accelerator
A~Z Of AcceleratorA~Z Of Accelerator
A~Z Of Acceleratorshen liu
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Railsshen liu
 
Rails + JCR
Rails + JCRRails + JCR
Rails + JCRshen liu
 
Legal contracts 2.0
Legal contracts 2.0Legal contracts 2.0
Legal contracts 2.0shen liu
 
危机模拟
危机模拟危机模拟
危机模拟shen liu
 
技术周报
技术周报技术周报
技术周报shen liu
 
InfoQ China Intro
InfoQ  China  IntroInfoQ  China  Intro
InfoQ China Introshen liu
 
QCon Beijing 2009 Intro
QCon Beijing 2009 IntroQCon Beijing 2009 Intro
QCon Beijing 2009 Introshen liu
 

More from shen liu (10)

A~Z Of Accelerator
A~Z Of AcceleratorA~Z Of Accelerator
A~Z Of Accelerator
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Rails
 
Rack
RackRack
Rack
 
Rails + JCR
Rails + JCRRails + JCR
Rails + JCR
 
Legal contracts 2.0
Legal contracts 2.0Legal contracts 2.0
Legal contracts 2.0
 
危机模拟
危机模拟危机模拟
危机模拟
 
决策
决策决策
决策
 
技术周报
技术周报技术周报
技术周报
 
InfoQ China Intro
InfoQ  China  IntroInfoQ  China  Intro
InfoQ China Intro
 
QCon Beijing 2009 Intro
QCon Beijing 2009 IntroQCon Beijing 2009 Intro
QCon Beijing 2009 Intro
 

Recently uploaded

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Douban Infrastructure Text Describes Web and Database Architecture

  • 1. Text 2009.4 hongqn@douban.com
  • 2. 2005 3 • • •
  • 3. • 2.8M 1/4 • • 20M / 500~600/sec • 23 PC (1U*15/2U*8) • 12 • 38G memcached
  • 4. 1U (frodo) • AMD Athlon 64 1.8GHz • 1G 160G SATA*2 • Gentoo Linux • MySQL 5 • Quixote (a Python web framework) • Lighttpd + SCGI (shire) • Memcached (!)
  • 5. Internet Lighttpd SCGI App FS MySQL Memcache Static Files
  • 6. Gentoo Linux • • emerge mysql • ebuild patch • • • GLSA(Gentoo Linux Security Advisories)
  • 7. MySQL • The world’s most popular open source database • / ==> MyISAM • ==> InnoDB • Replicate for backup
  • 8. Python • • Battery Included • • • CPUG: http://python.cn/
  • 9. Quixote • REST URL • Django, TurboGears, Pylons ZOPE • http://www.douban.com/subject/1000001 # luz/subject/__init__.py def _q_lookup(request, name): subject = get_subject(name) return lambda req: subject_ui(req, subject) # luz/subject/subject_ui.ptl def subject_ui [html] (request, subject): site_header(request) “<h1>%s</h1>” % subject.title site_footer(request)
  • 10. Lighttpd • • SCGI • SCGI: FastCGI Quixote • 80 lighttpd SCGI localhost Quixote
  • 11. Memcache • MySQL • libmemcache python Pyrex python 3x+ def get_subject(subject_id): subject = mc.get(‘s:’+subject_id) if subject is None: store.farm.execute(“select xxx, xxx from subject where id=%s”, subject_id) subject = Subject(*store.farm.fetchone()) mc.set(‘s:’+subject_id, subject) return subject
  • 12. • 1.2M / • IO •
  • 13. 1U • pippin meriadoc ( merry) • , 4G 250G SATA*3 • • IP DNS IP -_-b • frodo (subversion, trac, etc...)
  • 14. Internet Lighttpd (#$) DNS HTTP Proxy SCGI App Lighttpd (!quot;) FS Static Files Memcache MySQL
  • 15. • innodb_buffer_pool_size • • IP
  • 16. • 1.5M / • • IP
  • 17. IP(BGP) • (arwen) • 74G 1w SATA * 3 • •
  • 18. Internet Data Lighttpd Mining read SCGI write App Replicate MySQL MySQL Master Slave Memcache Static Files
  • 19. • 2M / • IO • , etc... •
  • 20. 4G 250G SATA*3 • 10000 • mod_rewrite URL • lighttpd mod_memcache • IO • web • •
  • 21. Internet store.farm App MySQL SCGI Master Lighttpd Memcache Replicate store.farmr HTTP Proxy WebDAV Web Service Replicate Lighttpd (w/ mod_memcache) MySQL write Slave Spiders Lighttpd WebDAV Memcache Static Files !quot;#$% read Data Mining MySQL Slave
  • 22. store farmr • replicate delay • • • cache • • • ...... but it works
  • 23. replicate delay def get_subject(sid): sbj = mc.get(‘s:’+sid) if sbj is None: sbj = flush_subject(sid, store.farmr) return sbj def flush_subject(sid, cursor=None): cursor = cursor or store.farm cursor.execute(“select ... from subject”) subject = Subject(*cursor.fetchone()) mc.set(‘s:’+sid, subject) return subject def update_subject(subject, props): store.farm.execute(“update subject ...”) store.farm.connection.commit() flush_subject(subject.id, store.farm)
  • 24. • 2.5M / • • / • SATA •
  • 25. Scale Up 1U • 16G 147G SCSI *2 + 500G SATA • SCSI RAID-0 • MySQL Slave • memcached • MyISAM InnoDB • • Sphinx
  • 26. Internet Sphinx MySQL Master store.farm Web Service Replicate Lighttpd SCGI App HTTP Proxy Memcache Lighttpd (w/ mod_memcache) WebDAV store.farmr Memcache Lighttpd Web Service WebDAV MySQL Static Files Slave Spiders Memcache Memcache
  • 27. • 5.2M / • • Web IO • •
  • 28. :) • • • • 3 1U 4 32G 1T SATA * 3 • otho.douban.com lotho.douban.com • lighttpd 1.5 with aio support • LVS • Scale Up: 4G -> 8G
  • 29. Internet www.douban.com otho.douban.com LVS LB (Master) Lighttpd Lighttpd 1.5 (w/ mod_cache) HTTP Proxy Lighttpd Keepalived LVS LB (backup) Lighttpd Lighttpd 1.5 WebDAV (w/ mod_cache) Static Files
  • 30. write !quot;#$% replicate read Data Mining MySQL MySQL Slave Master read Replicate write !quot;#$% Data Mining MySQL Slave
  • 31. • 6.4M / (5M PV) • • • CPU memcache /
  • 32. • lighttpd mod_scgi round-robin • lighttpd 1.5 • mod_proxy • proxy.balance = fair (load based, passive balancing) • • spread
  • 33. Internet Lighttpd SCGI HTTP Proxy App Memcache Lighttpd HTTP Proxy spread HTTP Proxy Lighttpd Lighttpd Log Aggregator SCGI spread Lighttpd Memcache App WebDAV Static Files
  • 34. • 11M / 3 • • Sphinx • • load
  • 35. • • • Sphinx -> Xapian • MogileFS
  • 36. libmemcache -> libmemcached consistent hash memcache • libmemcached consistent hash bug • CPU • libmemcached failover bug • nginx lighttpd load balance • spread • nginx
  • 37. !quot; Master replicate replicate !quot; %&'() Slave #$ Master read replicate Data #$ read Slave Mining write *+,- !quot; Master Slave replicate *+,- Slave write replicate Data %&'() Mining #$ Slave
  • 38. • • store.farm[r] -> store.get_cursor(table=‘xxx’, ro=True/False) def flush_subject(sid, ro=False): cursor = store.get_cursor(table=‘subject’, ro=ro) cursor.execute(“select ... from subject”) subject = Subject(*cursor.fetchone()) mc.set(‘s:’+sid, subject) return subject •
  • 39. Internet upload.douban.com otho.douban.com Lighttpd 1.5 signed POST form Uploader (w/ mod_cache) HTTP redirect FileStorage MogileFS Tracker Gateway App MogileFS MogileFS Node Node MogileFS Master
  • 40. Internet App SCGI Lighttpd HTTP Proxy Lighttpd HTTP Proxy App HTTP Proxy SCGI Lighttpd HTTP Proxy Nginx Lighttpd HTTP Proxy App Lighttpd SCGI Lighttpd WebDAV Static Files
  • 41. • 13M / • MogileFS • Tracker DB •
  • 42. 8 • 32G CPU • (300G SCSI×2 + 1T SATA) × 3 • (1T SATA × 3) × 5 •6 2 • DoubanFS
  • 43. DoubanFS • hash • hash hash • Merkle Tree • consistent hash • WebDAV • MogileFS 3 50
  • 46. Internet upload.douban.com otho.douban.com Lighttpd 1.5 signed POST form Uploader (w/ mod_cache) HTTP redirect FileStorage Gateway App DoubanFS DoubanFS Node Node
  • 47. • 16M / • • DoubanFS IO •
  • 48. DoubanDB • • MySQL • MySQL Master • failover • replicate delay
  • 49. DoubanDB • Key-Value • Amazon Dynamo • set(key, value), get(key), delete(key) • memcache • Merkle Tree • Consistent Hash • TokyoCabinet • DoubanDB • DoubanFS 2.0 DoubanDB
  • 50.
  • 51. !quot; Master1 replicate replicate !quot; %&'() Slave #$ Master1 read replicate Data #$ read Slave Mining write *+,- !quot; Master Master2 replicate *+,- Slave write replicate Data %&'() Mining #$ Master2
  • 52. DoubanFS • • • ngnix • www.douban.com LVS • RabbitMQ spread
  • 53. • • profile • memcache cache • join • •