SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
John Wood
                          ChicagoDB User Group
                             August 16, 2010

Monday, August 16, 2010
Outline
                    •     What is CouchDB?

                    •     Documents and Document Storage

                    •     Views

                    •     Replication

                    •     CouchApps

                    •     Add-ons

                    •     Resources

                    •     Demo!

Monday, August 16, 2010
What is CouchDB?



Monday, August 16, 2010
Document Database
                      {
                          “_id” : “2d7f015226a05b6940984bbe39004fde”,
                          “_rev” : “2-477f6ab2dec6df185de1a078d270d8”,
                          “first_name” : “John”,
                          “last_name” : “Wood”,
                          “interests” : [“hacking”, “fishing”, “running”],
                          “offspring” : [
                                          { “name” : “Dylan”, “age” : 5 },
                                          { “name” : “Chloe”, “age” : 2 }
                                        ]
                      }


Monday, August 16, 2010
Strong Focus on
                                                Replication




Monday, August 16, 2010
- Built from day one to support bi-directional peer to peer replication
- This feature sets CouchDB apart from the other NoSQL databases, and makes it stand out in the database community
RESTful API
                      # Create
                      POST http://localhost:5984/employees
                      # Read
                      GET http://localhost:5984/employees/1
                      # Update
                      PUT http://localhost:5984/employees/1
                      # Delete
                      DELETE http://localhost:5984/employees/1

Monday, August 16, 2010
Queried and Indexed
                           with MapReduce
                            function(doc) {
                              if (doc.first_name == “John”)
                                  emit(doc._id, 1);
                            }

                            function(keys, values, rereduce) {
                              return sum(values);
                            }


Monday, August 16, 2010
Multiversion
                           Concurrency Control




                                                                  http://en.wikipedia.org/wiki/Multiversion_concurrency_control
                                                     Image: http://blogs.wyomingnews.com/blogs/everyonegives/files/2009/02/book-stack.jpg

Monday, August 16, 2010
- Documents never updated in place; new revisions are always created
- Advantages
  * Don't have to manage locks for reads. Don't have to worry about a concurrent update corrupting a read that is in progress.
  * Data is “safer”. Old revisions are kept around (at least for a while). If a botched update accidentally destroys data, you can always restore it from a previous revision.
  * The database can perform some optimizations when writing to disk. If creating or updating 1000 documents, those documents will all live next to each other on disk, eliminating disk seeks.
- Disadvantages
  * Requires occasional database compaction
Ultra Durable




Monday, August 16, 2010
- When CouchDB documents are updated, all data and associated indexes are flushed to disk and the transactional commit always leaves the database in a completely consistent state.
- 2 step commit:
  * All document data and associated index updates are synchronously flushed to disk.
  * The database header is written in two consecutive, identical chunks, and flushed to disk.
- Crash recovery:
  * If crash on step 1 of commit, partially flushed data are forgotten upon restart.
  * If crash on step 2, a surviving copy of the previous headers will remain, and are used.
- Crash only shutdown
Erlang OTP




Monday, August 16, 2010
The Erlang programming language and the OTP platform are known for their concurrency support, and OTP is known for its extreme emphasis on reliability and
availability.
Monday, August 16, 2010
Documents and
                          Document Storage


Monday, August 16, 2010
Documents
                    • JSON data format
                    • Schema-less
                    • Support for binary data in the form of
                          document “attachments”
                    • Each document uniquely named in the
                          database


Monday, August 16, 2010
Document Storage
                    • CouchDB uses append-only updates, and
                          never overwrites comitted data
                    • Document updates are serialized
                    • Update model is lockless and optimistic
                    • Reads are never blocked or interrupted by
                          a concurrent updates
                    • Databases require occasional compaction
Monday, August 16, 2010
Views



Monday, August 16, 2010
Views
            • Add structure back to your unstructured data, so
                   it can be queried
            • Allow you to have many different view
                   representations of the same data
            • Created by executing map and reduce functions
                   on your documents
            • View definitions are stored in Design Documents
            • Built incrementally and on demand
Monday, August 16, 2010
MapReduce
                    • MapReduce functions are written primarily
                          in Javascript (some other languages are
                          supported)
                    • The map function selects which documents
                          to operate on, emitting zero to many key/
                          value pairs to the reduce function
                    • The (optional) reduce function combines
                          the key/value pairs and performs any
                          necessary calculations on that data

Monday, August 16, 2010
View Indexes
                    • View indexes are stored on disk separate
                          from the main database, in a data structure
                          specific to the given Design Document
                    • Views are updated incrementally; only new/
                          changed documents are processed when
                          the view is accessed
                    • Building views (especially from scratch) can
                          be time consuming and resource intensive
                          for large databases

Monday, August 16, 2010
Replication



Monday, August 16, 2010
Replication
          • Effecient and reliable bi-directional replication
          • Only documents created/updated since the last
                  replication are replicated
          • For each document, only updated fields are
                  replicated
          • Support for one-time, continuous, and filtered
                  replication
          • Fault tolerant - will simply pick up where it left off
                  if something bad happens
Monday, August 16, 2010
Conflict Management
        •       Documents with conflicts have a property named
                “_conflicts”, which contains all conflicting revision ids
        •       CouchDB chooses a winning document, but keeps
                losing documents around for manual conflict resolution
        •       CouchDB does not attempt to merge conflicting
                documents
        •       It is the application’s responsibility to make sure data is
                merged successfully
        •       Losing documents will be removed upon compaction
Monday, August 16, 2010
CouchApps



Monday, August 16, 2010
What are CouchApps?
          •       CouchApps are HTML and Javascript applications that
                  can be hosted directly from CouchDB
          •       CouchDB can serve HTML, images, CSS, Javascript, etc
          •       Applications live in a Design Document, with static
                  files (html, css, etc) as attachments
          •       Dynamic behavior and database access done via
                  Javascript
          •       CouchDB can be a complete, local web platform
          •       Support for virtual hosts and URL re-writing

Monday, August 16, 2010
Why?
          • Your application and its associated data can be
                  distributed, and replicated, together
          • If you like to share, somebody can grab your
                  application and data with a single replication
                  command
          • Not only Open Source, but Open Data as well
          • Applications can be taken off line, used, and
                  updated data can be synchronized at a later point
                  in time
Monday, August 16, 2010
Monday, August 16, 2010
http://pollen.nymphormation.org/afgwar/_design/afgwardiary/index.html


Monday, August 16, 2010
http://jchrisa.net/

Monday, August 16, 2010
http://jchrisa.net/cal/_design/cal/index.html

Monday, August 16, 2010
http://github.com/jchris/toast


Monday, August 16, 2010
Add-Ons

                    • couchdb-lucene - Enables full text searching
                          of documents using Lucene
                    • GeoCouch - Adds support for geospacial
                          queries to CouchDB
                    • Lounge - A proxy-based partitioning/
                          clustering framework for CouchDB



Monday, August 16, 2010
Resources

                          • http://apache.couchdb.org
                          • http://www.couch.io
                          • http://wiki.apache.org/couchdb
                          • http://books.couchdb.org/relax/
                          • http://wiki.couchapp.org

Monday, August 16, 2010
Less Talk, More Rock!
                                            Demo
                               http://github.com/jwood/couchdb_demo




Monday, August 16, 2010
Thanks!
                          john_p_wood@yahoo.com
                                @johnpwood




Monday, August 16, 2010

Contenu connexe

En vedette

INNOVATION: Being a journalist in the 2010s
INNOVATION: Being a journalist in the 2010sINNOVATION: Being a journalist in the 2010s
INNOVATION: Being a journalist in the 2010sKrisMcDonald21
 
CCMG Awards 2016 - Through the Looking Glass - February 2016
CCMG Awards 2016 - Through the Looking Glass - February 2016CCMG Awards 2016 - Through the Looking Glass - February 2016
CCMG Awards 2016 - Through the Looking Glass - February 2016Pommie Lutchman
 
Coana in international contemporary art 2012
Coana in international contemporary art 2012Coana in international contemporary art 2012
Coana in international contemporary art 2012Sebastiao Coana
 
Copyright why is it important for educators
Copyright  why is it important for educators Copyright  why is it important for educators
Copyright why is it important for educators Heather Borden
 
Beijing GNOME User Group
Beijing GNOME User GroupBeijing GNOME User Group
Beijing GNOME User GroupBin Li
 
Polyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherPolyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherJohn Wood
 
Mapas conceptuales.
Mapas conceptuales.Mapas conceptuales.
Mapas conceptuales.ijmentic
 
Sistema binario
Sistema binarioSistema binario
Sistema binarioijmentic
 

En vedette (16)

INNOVATION: Being a journalist in the 2010s
INNOVATION: Being a journalist in the 2010sINNOVATION: Being a journalist in the 2010s
INNOVATION: Being a journalist in the 2010s
 
Artist coana
Artist coanaArtist coana
Artist coana
 
CCMG Awards 2016 - Through the Looking Glass - February 2016
CCMG Awards 2016 - Through the Looking Glass - February 2016CCMG Awards 2016 - Through the Looking Glass - February 2016
CCMG Awards 2016 - Through the Looking Glass - February 2016
 
Coana artworks
Coana artworksCoana artworks
Coana artworks
 
Aries by bailey
Aries by baileyAries by bailey
Aries by bailey
 
Garden Bgiese
Garden BgieseGarden Bgiese
Garden Bgiese
 
Coana in international contemporary art 2012
Coana in international contemporary art 2012Coana in international contemporary art 2012
Coana in international contemporary art 2012
 
Copyright why is it important for educators
Copyright  why is it important for educators Copyright  why is it important for educators
Copyright why is it important for educators
 
Copyright
CopyrightCopyright
Copyright
 
Beijing GNOME User Group
Beijing GNOME User GroupBeijing GNOME User Group
Beijing GNOME User Group
 
Tenacity
TenacityTenacity
Tenacity
 
Aids
AidsAids
Aids
 
Polyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great TogetherPolyglot Persistence - Two Great Tastes That Taste Great Together
Polyglot Persistence - Two Great Tastes That Taste Great Together
 
Authoring CPAN modules
Authoring CPAN modulesAuthoring CPAN modules
Authoring CPAN modules
 
Mapas conceptuales.
Mapas conceptuales.Mapas conceptuales.
Mapas conceptuales.
 
Sistema binario
Sistema binarioSistema binario
Sistema binario
 

Similaire à Introduction to CouchDB

MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignDATAVERSITY
 
Sneak Peek of Nuxeo 5.4
Sneak Peek of Nuxeo 5.4Sneak Peek of Nuxeo 5.4
Sneak Peek of Nuxeo 5.4Nuxeo
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLAndreas Jung
 
Introducing apache pivot 2010 06-11
Introducing apache pivot 2010 06-11Introducing apache pivot 2010 06-11
Introducing apache pivot 2010 06-11ConchiLebron
 
An introduction to GWT and Ext GWT
An introduction to GWT and Ext GWTAn introduction to GWT and Ext GWT
An introduction to GWT and Ext GWTDarrell Meyer
 
The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010Voxilate
 
Seattle hug 2010
Seattle hug 2010Seattle hug 2010
Seattle hug 2010Abe Taha
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusioncolinbdclark
 
Puppet buero20 presentation
Puppet buero20 presentationPuppet buero20 presentation
Puppet buero20 presentationMartin Alfke
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGuillaume Laforge
 
Automation using-phing
Automation using-phingAutomation using-phing
Automation using-phingRajat Pandit
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby ConferenceJohn Woodell
 
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...Alluxio, Inc.
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Phase2
 
Implementing MongoDB at Shutterfly (Kenny Gorman)
Implementing MongoDB at Shutterfly (Kenny Gorman)Implementing MongoDB at Shutterfly (Kenny Gorman)
Implementing MongoDB at Shutterfly (Kenny Gorman)MongoSF
 
Scaling with mongo db (with notes)
Scaling with mongo db (with notes)Scaling with mongo db (with notes)
Scaling with mongo db (with notes)emiltamas
 

Similaire à Introduction to CouchDB (20)

MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Sneak Peek of Nuxeo 5.4
Sneak Peek of Nuxeo 5.4Sneak Peek of Nuxeo 5.4
Sneak Peek of Nuxeo 5.4
 
BRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQLBRAINREPUBLIC - Powered by no-SQL
BRAINREPUBLIC - Powered by no-SQL
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
Introducing apache pivot 2010 06-11
Introducing apache pivot 2010 06-11Introducing apache pivot 2010 06-11
Introducing apache pivot 2010 06-11
 
Noit ocon-2010
Noit ocon-2010Noit ocon-2010
Noit ocon-2010
 
An introduction to GWT and Ext GWT
An introduction to GWT and Ext GWTAn introduction to GWT and Ext GWT
An introduction to GWT and Ext GWT
 
The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010The Reluctant SysAdmin : 360|iDev Austin 2010
The Reluctant SysAdmin : 360|iDev Austin 2010
 
Seattle hug 2010
Seattle hug 2010Seattle hug 2010
Seattle hug 2010
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusion
 
Puppet buero20 presentation
Puppet buero20 presentationPuppet buero20 presentation
Puppet buero20 presentation
 
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume LaforgeGaelyk - SpringOne2GX - 2010 - Guillaume Laforge
Gaelyk - SpringOne2GX - 2010 - Guillaume Laforge
 
No sql findings
No sql findingsNo sql findings
No sql findings
 
Automation using-phing
Automation using-phingAutomation using-phing
Automation using-phing
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-Sensitive Queries for Presto at Facebook: A Collaboration ...
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
 
Couchdbkit & Dango
Couchdbkit & DangoCouchdbkit & Dango
Couchdbkit & Dango
 
Implementing MongoDB at Shutterfly (Kenny Gorman)
Implementing MongoDB at Shutterfly (Kenny Gorman)Implementing MongoDB at Shutterfly (Kenny Gorman)
Implementing MongoDB at Shutterfly (Kenny Gorman)
 
Scaling with mongo db (with notes)
Scaling with mongo db (with notes)Scaling with mongo db (with notes)
Scaling with mongo db (with notes)
 

Dernier

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Introduction to CouchDB

  • 1. John Wood ChicagoDB User Group August 16, 2010 Monday, August 16, 2010
  • 2. Outline • What is CouchDB? • Documents and Document Storage • Views • Replication • CouchApps • Add-ons • Resources • Demo! Monday, August 16, 2010
  • 3. What is CouchDB? Monday, August 16, 2010
  • 4. Document Database { “_id” : “2d7f015226a05b6940984bbe39004fde”, “_rev” : “2-477f6ab2dec6df185de1a078d270d8”, “first_name” : “John”, “last_name” : “Wood”, “interests” : [“hacking”, “fishing”, “running”], “offspring” : [ { “name” : “Dylan”, “age” : 5 }, { “name” : “Chloe”, “age” : 2 } ] } Monday, August 16, 2010
  • 5. Strong Focus on Replication Monday, August 16, 2010 - Built from day one to support bi-directional peer to peer replication - This feature sets CouchDB apart from the other NoSQL databases, and makes it stand out in the database community
  • 6. RESTful API # Create POST http://localhost:5984/employees # Read GET http://localhost:5984/employees/1 # Update PUT http://localhost:5984/employees/1 # Delete DELETE http://localhost:5984/employees/1 Monday, August 16, 2010
  • 7. Queried and Indexed with MapReduce function(doc) { if (doc.first_name == “John”) emit(doc._id, 1); } function(keys, values, rereduce) { return sum(values); } Monday, August 16, 2010
  • 8. Multiversion Concurrency Control http://en.wikipedia.org/wiki/Multiversion_concurrency_control Image: http://blogs.wyomingnews.com/blogs/everyonegives/files/2009/02/book-stack.jpg Monday, August 16, 2010 - Documents never updated in place; new revisions are always created - Advantages * Don't have to manage locks for reads. Don't have to worry about a concurrent update corrupting a read that is in progress. * Data is “safer”. Old revisions are kept around (at least for a while). If a botched update accidentally destroys data, you can always restore it from a previous revision. * The database can perform some optimizations when writing to disk. If creating or updating 1000 documents, those documents will all live next to each other on disk, eliminating disk seeks. - Disadvantages * Requires occasional database compaction
  • 9. Ultra Durable Monday, August 16, 2010 - When CouchDB documents are updated, all data and associated indexes are flushed to disk and the transactional commit always leaves the database in a completely consistent state. - 2 step commit: * All document data and associated index updates are synchronously flushed to disk. * The database header is written in two consecutive, identical chunks, and flushed to disk. - Crash recovery: * If crash on step 1 of commit, partially flushed data are forgotten upon restart. * If crash on step 2, a surviving copy of the previous headers will remain, and are used. - Crash only shutdown
  • 10. Erlang OTP Monday, August 16, 2010 The Erlang programming language and the OTP platform are known for their concurrency support, and OTP is known for its extreme emphasis on reliability and availability.
  • 12. Documents and Document Storage Monday, August 16, 2010
  • 13. Documents • JSON data format • Schema-less • Support for binary data in the form of document “attachments” • Each document uniquely named in the database Monday, August 16, 2010
  • 14. Document Storage • CouchDB uses append-only updates, and never overwrites comitted data • Document updates are serialized • Update model is lockless and optimistic • Reads are never blocked or interrupted by a concurrent updates • Databases require occasional compaction Monday, August 16, 2010
  • 16. Views • Add structure back to your unstructured data, so it can be queried • Allow you to have many different view representations of the same data • Created by executing map and reduce functions on your documents • View definitions are stored in Design Documents • Built incrementally and on demand Monday, August 16, 2010
  • 17. MapReduce • MapReduce functions are written primarily in Javascript (some other languages are supported) • The map function selects which documents to operate on, emitting zero to many key/ value pairs to the reduce function • The (optional) reduce function combines the key/value pairs and performs any necessary calculations on that data Monday, August 16, 2010
  • 18. View Indexes • View indexes are stored on disk separate from the main database, in a data structure specific to the given Design Document • Views are updated incrementally; only new/ changed documents are processed when the view is accessed • Building views (especially from scratch) can be time consuming and resource intensive for large databases Monday, August 16, 2010
  • 20. Replication • Effecient and reliable bi-directional replication • Only documents created/updated since the last replication are replicated • For each document, only updated fields are replicated • Support for one-time, continuous, and filtered replication • Fault tolerant - will simply pick up where it left off if something bad happens Monday, August 16, 2010
  • 21. Conflict Management • Documents with conflicts have a property named “_conflicts”, which contains all conflicting revision ids • CouchDB chooses a winning document, but keeps losing documents around for manual conflict resolution • CouchDB does not attempt to merge conflicting documents • It is the application’s responsibility to make sure data is merged successfully • Losing documents will be removed upon compaction Monday, August 16, 2010
  • 23. What are CouchApps? • CouchApps are HTML and Javascript applications that can be hosted directly from CouchDB • CouchDB can serve HTML, images, CSS, Javascript, etc • Applications live in a Design Document, with static files (html, css, etc) as attachments • Dynamic behavior and database access done via Javascript • CouchDB can be a complete, local web platform • Support for virtual hosts and URL re-writing Monday, August 16, 2010
  • 24. Why? • Your application and its associated data can be distributed, and replicated, together • If you like to share, somebody can grab your application and data with a single replication command • Not only Open Source, but Open Data as well • Applications can be taken off line, used, and updated data can be synchronized at a later point in time Monday, August 16, 2010
  • 30. Add-Ons • couchdb-lucene - Enables full text searching of documents using Lucene • GeoCouch - Adds support for geospacial queries to CouchDB • Lounge - A proxy-based partitioning/ clustering framework for CouchDB Monday, August 16, 2010
  • 31. Resources • http://apache.couchdb.org • http://www.couch.io • http://wiki.apache.org/couchdb • http://books.couchdb.org/relax/ • http://wiki.couchapp.org Monday, August 16, 2010
  • 32. Less Talk, More Rock! Demo http://github.com/jwood/couchdb_demo Monday, August 16, 2010
  • 33. Thanks! john_p_wood@yahoo.com @johnpwood Monday, August 16, 2010