Perform Like a frAg Star

3,431 views

Published on

A reworking of the infamous "CouchDB Perform Like a Pron Star" presentation, done for the Maine Ruby User Group

Published in: Education, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,431
On SlideShare
0
From Embeds
0
Number of Embeds
222
Actions
Shares
0
Downloads
36
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Perform Like a frAg Star

  1. 1. CouchDB Perform like a frAg star Casey Rosenthal Maine Ruby Users Group Slides by Renae Bair
  2. 2. How do you identify a developer/frAg star?
  3. 3. size - memory usage - amount of servers - infrastructure
  4. 4. reliability
  5. 5. fault-tolerant - no downtime - ready for traffic peaks - ready for more data
  6. 6. plays well with others
  7. 7. plays well with others - public interfaces - no discrimination
  8. 8. scalability
  9. 9. scalability - reaction under load - handle concurrent connections - number of requests/s - latency
  10. 10. performance
  11. 11. ¿frAg star?
  12. 12. kinda!
  13. 13. CouchDB Apache’s Document-Oriented Database
  14. 14. Relational Database Management Systems
  15. 15. Relational Database Management Systems Data Columns Relationships Tables Data Rows
  16. 16. RDBMS table name primary key structured data scalar values column name SQL consistency integrity constraints
  17. 17. RDBMS challenges for the web - most/all fields become optional - many-to-many relationships - joins - replication - auto incremental ids
  18. 18. RDBMS scaling is a pain
  19. 19. Column Oriented DBMS Hypertable Bigtable
  20. 20. Distributed Hash Table node B Key/Value node C Key/Value node A Key/Value node M Key/Value node L Key/Value node Z Key/Value
  21. 21. Distributed Hash Table -decentralized -add/remove nodes ➟ scale -fault tolerant -p2p & IM -memcached -memcached ➟ disk -MemcacheDB -Project Voldemort -Scalaris -Tokyo Cabinet -Redis
  22. 22. CouchDB
  23. 23. CouchDB
  24. 24. key/value store CouchDB Key: "user-077-socialsecuritynumber" value: "477-289-4690"
  25. 25. decentralized CouchDB
  26. 26. replication CouchDB
  27. 27. replication CouchDB
  28. 28. fault tolerant CouchDB
  29. 29. compute data CouchDB map/reduce built-in
  30. 30. compute data CouchDB function(doc) { if (doc.type == 'Card' && doc.tags) { doc.tags.forEach(function(tag){ emit(tag, 1); }) } }
  31. 31. more tricks
  32. 32. full ACID compliance
  33. 33. HTTP REST interface
  34. 34. Load Balancing
  35. 35. Caching
  36. 36. conflict management
  37. 37. MVCC Multiversion concurrency control
  38. 38. couchdb-lucene http://github.com/rnewson/couchdb-lucene/
  39. 39. ruby
  40. 40. couchrest
  41. 41. core couch = CouchRest.new("http://127.0.0.1:5984") db = couch.database!('GoGaRuCo') db.save_doc({ 'type' => 'attendee', 'first_name' => 'John', 'last_name' => 'Doe', 'age' => 32, 'tags' => ['Merb', 'MacRuby', 'JS'] })
  42. 42. more class Card < CouchRest::ExtendedDocument include CouchRest::Validation use_database SERVER.default_database property :first_name property :last_name, :alias => :family_name property :pid, :read_only => true timestamps! validates_present :first_name end
  43. 43. more Card.first Card.all Card.by_first_name(:key => 'Matt') Card.by_last_name(:keys => ['Aimonetti','Vega']) Card.get('matt_aimonetti') Card.by_phone_number( :startkey => [760,{}], :endkey => [815,{}])
  44. 44. more property :questions, :cast_as => ['Question'] property :professor, :cast_as => 'Person' property :final_test_at, :cast_as => 'Time'
  45. 45. more view_by :date, :descending => true view_by :user_id, :date
  46. 46. more view_by :tags, :map => "function(doc) { if (doc['couchrest-type'] == 'Article' && doc.tags) { doc.tags.forEach(function(tag){ emit(tag, 1); }); } }", :reduce => "function(keys, values, rereduce) { return sum(values); }"
  47. 47. more save_callback :before, :generate_slug_from_title
  48. 48. when to use couch? -when you need to scale your DB -when availability is more important than consistency -when your data is decentralized -when you need to compute data
  49. 49. Thanks

×