Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CouchDB

12,888 views

Published on

Published in: Technology
  • Use this weird secret involving text messages to get your Ex to come crawling back! Learn how ♣♣♣ http://scamcb.com/exback123/pdf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

CouchDB

  1. CouchDB
  2. Who’s talking? jan@apache.org / @janl And you?
  3. RDBMS vs Just Storing Data Sorry for bashing!
  4. RDBMS vs Just Storing Data Design schema upfront Write or use software to translate your data into that schema …and back 1) beware of speed considerations without having an app to measure 2) or use an ORM which turns out to be a pain in the back for all sorts of reasons 3) Most Data is not inherently relational
  5. RDBMS vs Just Storing Data Isolated data records called Documents No schema (!) and semi- structured data records that make up the app’s data objects
  6. Documents in the Real World
  7. Documents in the Real World Bills, tax forms, letters… Same type != same structure Can be out of date Natural data behaviour Actual data record, no pointer
  8. { “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true }
  9. { “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true }
  10. { “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true }
  11. { “_id”: ”BCCD12CBB”, “_rev”: ”AB764C”, “type”: ”person”, “name”: ”Darth Vader”, “age”: 63, “headware”: [“Helmet”, “Sombrero”], “dark_side”: true }
  12. CRUD — Arbeiten mit Dokumenten Create: HTTP POST /db/BCCD12CBB Read: HTTP GET /db/BCCD12CBB Update: HTTP PUT /db/BCCD12CBB Delete: HTTP DELETE /db/BCCD12CBB
  13. $ curl -X GET http://server/ database/document {“_id”:”ABC”,“_rev”:”1D4”,”data ”:...} $
  14. Zend_Http_Client <?php $url = 'http://server:5984/db/doc'; $client = new Zend_Http_Client($url); $response = $client->request('GET'); echo $response->getBody();
  15. PHPillow – Kore Nordmann <?php $doc = new myBlogDocument(); $doc->title = 'New blog post'; $doc->text = 'Hello world.'; $doc->save(); echo $doc->_id; $doc = myBlogDocument::fetchById('123');
  16. View of Keyes and Values
  17. Views Filter, Collate, Aggregate Powered by Map/Reduce Design documents functions get executed, you don’t do that
  18. View Examples – Docs by Date Key Value [2007, 10, 12, 20, 13, 12] {quot;_idquot;:quot;...quot;} [2007, 12, 26, 8, 37, 55] {quot;_idquot;:quot;...quot;} [2008, 2, 3, 10, 22, 34] {quot;_idquot;:quot;...quot;} [2008, 5, 1, 14, 16, 11] {quot;_idquot;:quot;...quot;}
  19. View Examples – Docs by Date function(doc) { emit(doc.date, doc); }
  20. View Examples – Docs by Date function(doc) { emit(<key>, <value>); }
  21. Views Built incrementally… …and on demand Reduce optional map/reduce can be parallelised
  22. Replication
  23. Replication Easy Data Synchronization Without Headaches
  24. Replication Take your data with you CouchDB makes it easy to synchronise machines rsync-like Large spectrum of architectures: - P2P, Failover, Load Balancing, Backup Conflicts: auto-detect & resolve, data consistency
  25. Built for the Future Written in Erlang - a telco- grade concurrent platform Non-locking MVCC and ACID compliant data store Erlang Processes + messaging Ericsson AXD 301 - nine nines - 1/30th second per year Crash resistant
  26. Number Bragging Silly read-only benchmark with memory saturation 2,500 req/s sustained on a 2Ghz dual core Athlon
  27. Number Bragging Silly read-only benchmark with memory saturation 2,500 req/s sustained on a 2Ghz dual core Athlon Using 9.8 MB RAM
  28. A Little History Damien Katz self funded fulltime development for 2 years Now backed by IBM
  29. A Little History Accepted to the Apache Software Foundation Open Source License
  30. Thank You!
  31. Bonus Slides
  32. Where is my auto increment What is auto_increment? Unique identifier Sequence denominator
  33. Where is my auto_increment? Documents have `_id`s Sequences in distributed applications are not Timestamps get you a long way, though.
  34. Relation(ship)s JOINs plz! What for? Get data that “belongs together”
  35. Relation(ship)s One big fat doc? Pros: Easy – Cons: Bad with the concurrent updates Use for: Low volume updates e.g. user-supplied tags
  36. Relation(ship)s Master Doc – Slave Doc Pros: A little complex – Cons: Fast, good with concurrent updates, tree operations Use for: Everything else
  37. Relation(ship)s function(doc) { if(doc.ismaster) { emit([doc._id, doc.date], doc); } else { emit([doc.master_id, doc.date], doc); } }
  38. Relation(ship)s ... ... [quot;BAAC67quot;, quot;2008-09-21quot;] {quot;is_parentquot;,true} [quot;BAAC67quot;, quot;2008-09-22quot;] {quot;...quot;,quot;...quot;} [quot;BAAC67quot;, quot;2008-09-23quot;] {quot;...quot;,quot;...quot;} [quot;BAAC67quot;, quot;2008-09-24quot;] {quot;...quot;,quot;...quot;} ... ...
  39. Transactions! Run multiple operations at once They all succeed or none gets applied
  40. Transactions POST { quot;docsquot;: [ {quot;_idquot;: quot;0quot;, quot;intquot;: 0, quot;strquot;: quot;0quot;}, {quot;_idquot;: quot;1quot;, quot;intquot;: 1, quot;strquot;: quot;1quot;}, {quot;_idquot;: quot;2quot;, quot;intquot;: 2, quot;strquot;: quot;2quot;} ] }
  41. Transactions! Caveats: Statement transaction No data transaction No multi-node transactions
  42. Multi-Node Transactions! Why? – Data redundancy Use an HTTP proxy Nice to build on standard protocols Caveat: 2-phase-commit in disguise
  43. MapReduce
  44. View Examples – Docs by Date Map Key Value [2007, 10, 12, 20, 13, 12] 3465 [2007, 12, 26, 8, 37, 55] 4200 [2008, 2, 3, 10, 22, 34] 3782 [2008, 5, 1, 14, 16, 11] 5984
  45. View Examples – Docs by Date Reduce Key Value null 17431
  46. View Examples – Docs by Date Reduce with group_level=1 Key Value [2007] 7665 [2008] 9766
  47. View Examples – Docs by Date Map Key Value [2007, 10, 12, 20, 13, 12] 3465 [2007, 12, 26, 8, 37, 55] 4200 [2008, 2, 3, 10, 22, 34] 3782 [2008, 5, 1, 14, 16, 11] 5984
  48. Hot backup? POSIX compliant
  49. Hot backup? $ cp -r /var/lib/couchdb/* /mnt/backup
  50. Resources Twitter: @CouchDB & http://couchdb.org/ Dress like a Couch: http://shop.couchdb.com http://damienkatz.net/ & http://jan.prima.de/ http://blog.racklabs.com/?p=74 https://peepcode.com/products/couchdb- with-rails not covered everything, other talks + tutorials
  51. Thank You Really, thanks.
  52. Got it? Questions
  53. Built for the Future “640k processors should be enough for anybody.”
  54. Single-user machines Back then
  55. Multi-user machines Now
  56. Application: Science Back then
  57. Application: Internet Today
  58. Monolithic machines Back then
  59. Lots of small servers Today
  60. CPU, RAM and disks == $$$ Back then
  61. Components cheaper Now

×